@colyseus/tools 0.15.33 → 0.15.35
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/post-deploy.js +46 -16
package/package.json
CHANGED
package/post-deploy.js
CHANGED
|
@@ -32,20 +32,43 @@ pm2.list(function(err, apps) {
|
|
|
32
32
|
pm2.start(CONFIG_FILE, {...opts}, onAppRunning);
|
|
33
33
|
|
|
34
34
|
} else {
|
|
35
|
-
// reload existing apps
|
|
36
|
-
pm2.reload(CONFIG_FILE, {...opts}, function(err, apps) {
|
|
37
|
-
bailOnErr(err);
|
|
38
35
|
|
|
39
|
-
|
|
36
|
+
//
|
|
37
|
+
// detect if cwd has changed, and restart PM2 if it has
|
|
38
|
+
//
|
|
39
|
+
if (apps[0].pm2_env.pm_cwd !== pm2.cwd) {
|
|
40
40
|
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
//
|
|
42
|
+
// remove all and start again with new cwd
|
|
43
|
+
//
|
|
44
|
+
pm2.delete('all', function(err) {
|
|
45
|
+
|
|
46
|
+
// kill & start again
|
|
47
|
+
pm2.kill(function() {
|
|
48
|
+
pm2.start(CONFIG_FILE, { ...opts }, onAppRunning);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
} else {
|
|
54
|
+
//
|
|
55
|
+
// reload existing apps
|
|
56
|
+
//
|
|
57
|
+
pm2.reload(CONFIG_FILE, {...opts}, function(err, apps) {
|
|
58
|
+
bailOnErr(err);
|
|
59
|
+
|
|
60
|
+
const name = apps[0].name;
|
|
61
|
+
|
|
62
|
+
// scale app to use all CPUs available
|
|
63
|
+
if (apps.length !== maxCPU) {
|
|
64
|
+
pm2.scale(name, maxCPU, onAppRunning);
|
|
65
|
+
|
|
66
|
+
} else {
|
|
67
|
+
onAppRunning();
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
44
71
|
|
|
45
|
-
} else {
|
|
46
|
-
onAppRunning();
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
72
|
}
|
|
50
73
|
});
|
|
51
74
|
|
|
@@ -67,7 +90,7 @@ function updateColyseusBootService() {
|
|
|
67
90
|
}
|
|
68
91
|
|
|
69
92
|
const workingDirectory = pm2.cwd;
|
|
70
|
-
const execStart = `${detectPackageManager()}
|
|
93
|
+
const execStart = `${detectPackageManager()} colyseus-post-deploy`;
|
|
71
94
|
|
|
72
95
|
const contents = fs.readFileSync(COLYSEUS_CLOUD_BOOT_SERVICE, 'utf8');
|
|
73
96
|
try {
|
|
@@ -123,10 +146,17 @@ function updateAndReloadNginx() {
|
|
|
123
146
|
|
|
124
147
|
function detectPackageManager() {
|
|
125
148
|
const lockfiles = {
|
|
126
|
-
npm
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
149
|
+
// npm
|
|
150
|
+
"npm exec": path.resolve(pm2.cwd, 'package-lock.json'),
|
|
151
|
+
|
|
152
|
+
// yarn
|
|
153
|
+
"yarn exec": path.resolve(pm2.cwd, 'yarn.lock'),
|
|
154
|
+
|
|
155
|
+
// pnpm
|
|
156
|
+
"pnpm exec": path.resolve(pm2.cwd, 'pnpm-lock.yaml'),
|
|
157
|
+
|
|
158
|
+
// bun
|
|
159
|
+
"bunx": path.resolve(pm2.cwd, 'bun.lockb'),
|
|
130
160
|
};
|
|
131
161
|
|
|
132
162
|
for (const [key, value] of Object.entries(lockfiles)) {
|