update
This commit is contained in:
33
ts/cli/commands/service/enable.ts
Normal file
33
ts/cli/commands/service/enable.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import * as plugins from '../../../plugins.js';
|
||||
import { TspmServiceManager } from '../../../classes.servicemanager.js';
|
||||
import { Logger } from '../../../utils.errorhandler.js';
|
||||
import type { CliArguments } from '../../types.js';
|
||||
|
||||
export function registerEnableCommand(smartcli: plugins.smartcli.Smartcli) {
|
||||
const cliLogger = new Logger('CLI');
|
||||
|
||||
smartcli.addCommand('enable').subscribe({
|
||||
next: async (argvArg: CliArguments) => {
|
||||
try {
|
||||
const serviceManager = new TspmServiceManager();
|
||||
console.log('Enabling TSPM daemon as system service...');
|
||||
|
||||
await serviceManager.enableService();
|
||||
|
||||
console.log('✓ TSPM daemon enabled and started as system service');
|
||||
console.log(' The daemon will now start automatically on system boot');
|
||||
console.log(' Use "tspm disable" to remove the service');
|
||||
} catch (error) {
|
||||
console.error('Error enabling service:', error.message);
|
||||
if (error.message.includes('permission') || error.message.includes('denied')) {
|
||||
console.log('\nNote: You may need to run this command with sudo');
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
},
|
||||
error: (err) => {
|
||||
cliLogger.error(err);
|
||||
},
|
||||
complete: () => {},
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user