smartdaemon/ts/smartdaemon.classes.templatemanager.ts

42 lines
980 B
TypeScript
Raw Normal View History

2019-09-03 09:29:14 +00:00
import * as plugins from './smartdaemon.plugins';
2019-09-03 13:21:30 +00:00
import { SmartDaemon } from './smartdaemon.classes.smartdaemon';
2019-09-03 09:29:14 +00:00
export class SmartDaemonTemplateManager {
2019-09-03 13:21:30 +00:00
public smartdaemonRef: SmartDaemon;
constructor(smartdaemonRefArg: SmartDaemon) {
this.smartdaemonRef = smartdaemonRefArg;
}
2019-09-03 09:29:14 +00:00
public generateServiceTemplate = (optionsArg: {
serviceName: string;
description: string;
serviceVersion: string;
2019-09-03 13:21:30 +00:00
command: string;
2019-09-03 09:29:14 +00:00
pathWorkkingDir;
pathJsFileToRun;
}) => {
return `
# servicVersion: ${optionsArg.serviceVersion}
[Unit]
Description=${optionsArg.description}
Requires=network.target
After=network.target
[Service]
Type=simple
2019-09-03 13:21:30 +00:00
ExecStart=/bin/bash -c "cd ${optionsArg.pathWorkkingDir} && ${optionsArg.command}"
2019-09-03 09:29:14 +00:00
WorkingDirectory=${optionsArg.pathWorkkingDir}
Restart=on-failure
LimitNOFILE=infinity
LimitCORE=infinity
StandardInput=null
StandardOutput=syslog
StandardError=syslog
Restart=always
[Install]
WantedBy=multi-user.target
`;
2019-09-03 13:21:30 +00:00
}
2019-09-03 09:29:14 +00:00
}