@colyseus/tools 0.15.47 → 0.15.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/pm2/post-deploy-agent.js +10 -7
- package/post-deploy.js +3 -6
package/package.json
CHANGED
package/pm2/post-deploy-agent.js
CHANGED
|
@@ -79,21 +79,19 @@ function postDeploy(cwd, reply) {
|
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
console.log("apps[0].pm2_env.pm_cwd =>", apps[0].pm2_env.pm_cwd);
|
|
83
|
-
console.log("cwd =>", cwd);
|
|
84
|
-
|
|
85
82
|
//
|
|
86
83
|
// detect if cwd has changed, and restart PM2 if it has
|
|
87
84
|
//
|
|
88
85
|
if (apps[0].pm2_env.pm_cwd !== cwd) {
|
|
89
|
-
console.log("
|
|
86
|
+
console.log("App Root Directory changed. Restarting may take a bit longer...");
|
|
90
87
|
|
|
91
88
|
//
|
|
92
89
|
// remove all and start again with new cwd
|
|
93
90
|
//
|
|
94
|
-
return pm2.delete(
|
|
91
|
+
return pm2.delete('all', function (err) {
|
|
92
|
+
logIfError(err);
|
|
93
|
+
|
|
95
94
|
// start again
|
|
96
|
-
// (TODO: make sure CWD is actually changed after this...)
|
|
97
95
|
pm2.start(config, { ...opts }, (err, result) => {
|
|
98
96
|
reply({ success: !err, message: err?.message });
|
|
99
97
|
updateAndSave(err, result);
|
|
@@ -133,7 +131,7 @@ function postDeploy(cwd, reply) {
|
|
|
133
131
|
* - Stop old processes
|
|
134
132
|
* - Spawn/reactivate the rest of the processes (shared.MAX_ACTIVE_PROCESSES)
|
|
135
133
|
*/
|
|
136
|
-
const onFirstAppsStart = (initialApps, err, result) => {
|
|
134
|
+
const onFirstAppsStart = async (initialApps, err, result) => {
|
|
137
135
|
/**
|
|
138
136
|
* release post-deploy action while proceeding with graceful restart of other processes
|
|
139
137
|
*/
|
|
@@ -149,6 +147,11 @@ function postDeploy(cwd, reply) {
|
|
|
149
147
|
*/
|
|
150
148
|
writeNginxConfig(initialApps);
|
|
151
149
|
|
|
150
|
+
//
|
|
151
|
+
// Wait 1.5 seconds to ensure NGINX is updated & reloaded
|
|
152
|
+
//
|
|
153
|
+
await new Promise(resolve => setTimeout(resolve, 1500));
|
|
154
|
+
|
|
152
155
|
//
|
|
153
156
|
// Asynchronously stop/restart apps with active connections
|
|
154
157
|
// (They make take from minutes up to hours to stop)
|
package/post-deploy.js
CHANGED
|
@@ -22,8 +22,6 @@ if (!CONFIG_FILE) {
|
|
|
22
22
|
|
|
23
23
|
const CONFIG_FILE_PATH = `${pm2.cwd}/${CONFIG_FILE}`;
|
|
24
24
|
|
|
25
|
-
let config = undefined;
|
|
26
|
-
|
|
27
25
|
/**
|
|
28
26
|
* Try to handle post-deploy via PM2 module first (pm2 install @colyseus/tools)
|
|
29
27
|
* If not available, fallback to legacy post-deploy script.
|
|
@@ -31,7 +29,6 @@ let config = undefined;
|
|
|
31
29
|
pm2.trigger('@colyseus/tools', 'post-deploy', `${pm2.cwd}:${CONFIG_FILE_PATH}`, async function (err, result) {
|
|
32
30
|
if (err) {
|
|
33
31
|
console.log("Proceeding with legacy post-deploy script...");
|
|
34
|
-
config = await shared.getAppConfig(CONFIG_FILE_PATH);
|
|
35
32
|
postDeploy();
|
|
36
33
|
|
|
37
34
|
} else {
|
|
@@ -53,7 +50,7 @@ async function postDeploy() {
|
|
|
53
50
|
//
|
|
54
51
|
// first deploy
|
|
55
52
|
//
|
|
56
|
-
pm2.start(
|
|
53
|
+
pm2.start(CONFIG_FILE_PATH, { ...opts }, () => onAppRunning());
|
|
57
54
|
|
|
58
55
|
} else {
|
|
59
56
|
|
|
@@ -88,13 +85,13 @@ function restartAll () {
|
|
|
88
85
|
pm2.delete('all', function (err) {
|
|
89
86
|
// kill & start again
|
|
90
87
|
pm2.kill(function () {
|
|
91
|
-
pm2.start(
|
|
88
|
+
pm2.start(CONFIG_FILE_PATH, { ...opts }, () => onAppRunning());
|
|
92
89
|
});
|
|
93
90
|
});
|
|
94
91
|
}
|
|
95
92
|
|
|
96
93
|
function reloadAll(retry = 0) {
|
|
97
|
-
pm2.reload(
|
|
94
|
+
pm2.reload(CONFIG_FILE_PATH, { ...opts }, function (err, apps) {
|
|
98
95
|
if (err) {
|
|
99
96
|
//
|
|
100
97
|
// Retry in case of "Reload in progress" error.
|