Skip to content

Commit 536645e

Browse files
committed
fix deploy:migrate on stopped server
1 parent e2fde42 commit 536645e

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

modules/deploy/tasks/migrate.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,17 @@ module.exports = function() {
2727

2828
gutil.log("Migrations found, stopping to apply, in maintenance mode");
2929
fs.writeFileSync(path.join(projectRoot, '.maintenance'), '');
30-
execSync('/usr/local/bin/pm2 stop all'); // todo gracefulShutdown
3130

31+
try {
32+
execSync('/usr/local/bin/pm2 stop all'); // todo gracefulShutdown
33+
} catch(e) {
34+
if (e.code == 1) {
35+
// OK
36+
// [PM2][WARN] No process found (already stopped)
37+
} else {
38+
throw e;
39+
}
40+
}
3241
gutil.log("Migrations, applying all up");
3342

3443
yield migrationManager.migrateAllUp();

modules/deploy/tasks/update.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module.exports = function() {
3131
yield* client.runInTarget(`git merge origin/production --no-edit`);
3232

3333
// if there any migrations, this will stop the server and apply them
34-
yield* client.runInTarget(`gulp deploy:migrate`);
34+
yield* client.runInTarget(`gulp deploy:migrate --stop`);
3535

3636
yield* client.runInTarget(`/usr/local/bin/pm2 startOrGracefulReload ecosystem.json --env production`);
3737
yield* client.runInTarget(`gulp cache:clean`);

0 commit comments

Comments
 (0)