fixup various shell usage

This commit is contained in:
Girish Ramakrishnan
2024-02-28 18:47:53 +01:00
parent 07527fe2b1
commit 3316dd1f42
4 changed files with 47 additions and 21 deletions
+31 -12
View File
@@ -952,8 +952,11 @@ async function startTurn(existingInfra) {
--label isCloudronManaged=true \
${readOnly} -v /tmp -v /run ${image} ${cmd}`;
await safe(shell.exec('stopTurn', 'docker stop turn', {})); // ignore error
await safe(shell.exec('removeTurn', 'docker rm -f turn', {})); // ignore error
debug('startTurn: stopping and deleting previous turn container');
await docker.stopContainer('turn');
await docker.deleteContainer('turn');
debug('startTurn: starting turn container');
await shell.exec('startTurn', runCmd, { shell: '/bin/bash' });
}
@@ -1159,8 +1162,11 @@ async function startMysql(existingInfra) {
--cap-add SYS_NICE \
${readOnly} -v /tmp -v /run ${image} ${cmd}`;
await safe(shell.exec('stopMysql', 'docker stop mysql', {})); // ignore error
await safe(shell.exec('removeMysql', 'docker rm -f mysql', {})); // ignore error
debug('startMysql: stopping and deleting previous mysql container');
await docker.stopContainer('mysql');
await docker.deleteContainer('mysql');
debug('startMysql: starting mysql container');
await shell.exec('startMysql', runCmd, { shell: '/bin/bash' });
if (!serviceConfig.recoveryMode) {
@@ -1378,8 +1384,11 @@ async function startPostgresql(existingInfra) {
--label isCloudronManaged=true \
${readOnly} -v /tmp -v /run ${image} ${cmd}`;
await safe(shell.exec('stopPostgresql', 'docker stop postgresql', {})); // ignore error
await safe(shell.exec('removePostgresql', 'docker rm -f postgresql', {})); // ignore error
debug('startPostgresqk: stopping and deleting previous postgresql container');
await docker.stopContainer('postgresql');
await docker.deleteContainer('postgresql');
debug('startPostgresql: starting postgresql container');
await shell.exec('startPostgresql', runCmd, { shell: '/bin/bash' });
if (!serviceConfig.recoveryMode) {
@@ -1521,8 +1530,11 @@ async function startMongodb(existingInfra) {
--label isCloudronManaged=true \
${readOnly} -v /tmp -v /run ${image} ${cmd}`;
await safe(shell.exec('stopMongodb', 'docker stop mongodb', {})); // ignore error
await safe(shell.exec('removeMongodb', 'docker rm -f mongodb', {})); // ignore error
debug('startMongodb: stopping and deleting previous mongodb container');
await docker.stopContainer('mongodb');
await docker.deleteContainer('mongodb');
debug('startMongodb: starting mongodb container');
await shell.exec('startMongodb', runCmd, { shell: '/bin/bash' });
if (!serviceConfig.recoveryMode) {
@@ -1669,9 +1681,13 @@ async function startGraphite(existingInfra) {
--label isCloudronManaged=true \
${readOnly} -v /tmp -v /run ${image} ${cmd}`;
await safe(shell.exec('stopGraphite', 'docker stop graphite', {})); // ignore error
await safe(shell.exec('removeGraphite', 'docker rm -f graphite', {})); // ignore error
debug('startGraphite: stopping and deleting previous graphite container');
await docker.stopContainer('graphite');
await docker.deleteContainer('graphite');
if (upgrading) await shell.promises.sudo('removeGraphiteDir', [ RMADDONDIR_CMD, 'graphite' ], {});
debug('startGraphite: starting graphite container');
await shell.exec('startGraphite', runCmd, { shell: '/bin/bash' });
// restart collectd to get the disk stats after graphite starts. currently, there is no way to do graphite health check
@@ -1714,8 +1730,11 @@ async function startRedis(existingInfra) {
if (upgrading) await backupRedis(app, {});
await safe(shell.exec('stopRedis', `docker stop ${redisName}`, {})); // redis will backup as part of signal handling
await safe(shell.exec('removeRedis', `docker rm -f ${redisName}`, {})); // ignore error
debug(`startRedis: stopping and deleting previous redis container ${redisName}`);
await docker.stopContainer(redisName);
await docker.deleteContainer(redisName);
debug(`startRedis: starting redis container ${redisName}`);
await setupRedis(app, app.manifest.addons.redis); // starts the container
}