feat(systemd): support configurable service environment variables
This commit is contained in:
@@ -54,6 +54,29 @@ tap.test('should generate systemd unit file with User/Group directives', async (
|
||||
expect(unitFileContent).toInclude('Group=www-data');
|
||||
expect(unitFileContent).toInclude('# user: www-data');
|
||||
expect(unitFileContent).toInclude('# group: www-data');
|
||||
expect(unitFileContent).not.toInclude('max_old_space_size=100');
|
||||
});
|
||||
|
||||
tap.test('should generate systemd unit file with configured environment', async () => {
|
||||
const testService = await smartdaemon.SmartDaemonService.createFromOptions(
|
||||
testSmartdaemon,
|
||||
{
|
||||
name: 'test-service-env',
|
||||
description: 'A test service with environment',
|
||||
command: 'node test.js',
|
||||
workingDir: '/tmp',
|
||||
version: '1.0.0',
|
||||
environment: {
|
||||
NODE_OPTIONS: '--max_old_space_size=1024',
|
||||
CUSTOM_VALUE: 'quoted "value"',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const unitFileContent = testSmartdaemon.templateManager.generateUnitFileForService(testService);
|
||||
|
||||
expect(unitFileContent).toInclude('Environment="NODE_OPTIONS=--max_old_space_size=1024"');
|
||||
expect(unitFileContent).toInclude('Environment="CUSTOM_VALUE=quoted \\"value\\""');
|
||||
});
|
||||
|
||||
tap.test('should handle services without user/group', async () => {
|
||||
@@ -82,4 +105,4 @@ tap.test('should create smartdaemon with sudo password option', async () => {
|
||||
expect(daemonWithPassword.systemdManager.sudoPassword).toEqual('test-password');
|
||||
});
|
||||
|
||||
export default tap.start();
|
||||
export default tap.start();
|
||||
|
||||
Reference in New Issue
Block a user