feat(cli): add commands for starting and stopping apps

This commit is contained in:
Nicolas Meienberger 2023-10-23 07:41:31 +02:00 committed by Nicolas Meienberger
parent b1cd37ddba
commit 9f1e09098a
2 changed files with 21 additions and 2 deletions

View file

@ -152,10 +152,10 @@ export class AppExecutors {
try {
this.logger.info(`Stopping app ${appId}`);
this.logger.info(`Regenerating app.env file for app ${appId}`);
await this.ensureAppDir(appId);
if (!skipEnvGeneration) {
this.logger.info(`Regenerating app.env file for app ${appId}`);
await generateEnvFile(appId, config);
}
await compose(appId, 'rm --force --stop');

View file

@ -4,7 +4,7 @@ import { program } from 'commander';
import chalk from 'chalk';
import { description, version } from '../package.json';
import { startWorker } from './services/watcher/watcher';
import { SystemExecutors } from './executors';
import { AppExecutors, SystemExecutors } from './executors';
const main = async () => {
program.description(description).version(version);
@ -69,6 +69,25 @@ const main = async () => {
await systemExecutors.cleanLogs();
});
// Start app: ./cli app start <app>
// Stop app: ./cli app stop <app>
program
.command('app [command] <app>')
.description('App management')
.action(async (command, app) => {
const appExecutors = new AppExecutors();
switch (command) {
case 'start':
await appExecutors.startApp(app, {});
break;
case 'stop':
await appExecutors.stopApp(app, {}, true);
break;
default:
console.log(chalk.red('✗'), 'Unknown command');
}
});
program.parse(process.argv);
};