fix(worker): docker not throwing an error when failing to start

This commit is contained in:
Nicolas Meienberger 2023-11-15 18:48:08 +01:00 committed by Nicolas Meienberger
parent af8509aacc
commit bdfb019df2
7 changed files with 11 additions and 57 deletions

5
.gitignore vendored
View File

@ -54,9 +54,7 @@ node_modules/
/data/
/repos/
/apps/
traefik/shared
traefik/tls
./traefik/
/traefik/
# media folder
media
@ -68,3 +66,4 @@ media
temp
./traefik/
/user-config/

View File

@ -11,7 +11,7 @@
"test:client": "jest --colors --selectProjects client --",
"test:server": "jest --colors --selectProjects server --",
"test:vite": "dotenv -e .env.test -- vitest run --coverage",
"dev": "npm run db:migrate && next dev",
"dev": "next dev",
"dev:watcher": "pnpm -r --filter cli dev",
"db:migrate": "NODE_ENV=development dotenv -e .env.local -- tsx ./src/server/run-migrations-dev.ts",
"lint": "next lint",

View File

@ -41,47 +41,6 @@ export class SystemExecutors {
return { success: false, message: `An error occurred: ${err}` };
};
// private ensureFilePermissions = async (rootFolderHost: string) => {
// const logger = new TerminalSpinner('');
// const filesAndFolders = [
// path.join(rootFolderHost, 'apps'),
// path.join(rootFolderHost, 'logs'),
// path.join(rootFolderHost, 'repos'),
// path.join(rootFolderHost, 'state'),
// path.join(rootFolderHost, 'traefik'),
// path.join(rootFolderHost, '.env'),
// path.join(rootFolderHost, 'VERSION'),
// path.join(rootFolderHost, 'docker-compose.yml'),
// ];
// const files600 = [path.join(rootFolderHost, 'traefik', 'shared', 'acme.json')];
// this.logger.info('Setting file permissions a+rwx on required files');
// // Give permission to read and write to all files and folders for the current user
// for (const fileOrFolder of filesAndFolders) {
// if (await pathExists(fileOrFolder)) {
// this.logger.info(`Setting permissions on ${fileOrFolder}`);
// await execAsync(`chmod -R a+rwx ${fileOrFolder}`).catch(() => {
// logger.fail(`Failed to set permissions on ${fileOrFolder}`);
// });
// this.logger.info(`Successfully set permissions on ${fileOrFolder}`);
// }
// }
// this.logger.info('Setting file permissions 600 on required files');
// for (const fileOrFolder of files600) {
// if (await pathExists(fileOrFolder)) {
// this.logger.info(`Setting permissions on ${fileOrFolder}`);
// await execAsync(`chmod 600 ${fileOrFolder}`).catch(() => {
// logger.fail(`Failed to set permissions on ${fileOrFolder}`);
// });
// this.logger.info(`Successfully set permissions on ${fileOrFolder}`);
// }
// }
// };
public cleanLogs = async () => {
try {
await this.logger.flush();

View File

@ -9,7 +9,8 @@
"build": "node build.js",
"tsc": "tsc",
"dev": "dotenv -e ../../.env nodemon",
"knip": "knip"
"knip": "knip",
"lint": "eslint . --ext .ts"
},
"keywords": [],
"author": "",

View File

@ -8,6 +8,10 @@ const composeUp = async (args: string[]) => {
logger.info(`Running docker compose with args ${args.join(' ')}`);
const { stdout, stderr } = await execAsync(`docker compose ${args.join(' ')}`);
if (stderr && stderr.includes('Command failed:')) {
throw new Error(stderr);
}
return { stdout, stderr };
};

View File

@ -130,12 +130,7 @@ export class AppExecutors {
// run docker-compose up
this.logger.info(`Running docker-compose up for app ${appId}`);
const { stderr } = await compose(appId, 'up -d');
if (stderr) {
this.logger.error(`Error running docker-compose up for app ${appId}: ${stderr}`);
return { success: false, message: `Error running docker-compose up for app ${appId}: ${stderr}` };
}
await compose(appId, 'up -d');
this.logger.info(`Docker-compose up for app ${appId} finished`);

View File

@ -87,11 +87,7 @@ export class RepoExecutors {
});
this.logger.info(`Executing: git -C ${repoPath} fetch origin && git -C ${repoPath} reset --hard origin/${currentBranch}`);
await execAsync(`git -C ${repoPath} fetch origin && git -C ${repoPath} reset --hard origin/${currentBranch}`).then(({ stderr }) => {
if (stderr) {
this.logger.error(`stderr: ${stderr}`);
}
});
await execAsync(`git -C ${repoPath} fetch origin && git -C ${repoPath} reset --hard origin/${currentBranch}`);
this.logger.info(`Pulled repo ${repoUrl} to ${repoPath}`);
return { success: true, message: '' };