wiki-plugin-allyabase 0.0.9 → 0.0.10

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/server/server.js +18 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wiki-plugin-allyabase",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "Allyabase management plugin for the federated wiki",
5
5
  "keywords": [
6
6
  "wiki",
package/server/server.js CHANGED
@@ -153,24 +153,28 @@ function killProcessByPort(port) {
153
153
  });
154
154
  }
155
155
 
156
- // Function to stop PM2-managed allyabase services (not the daemon itself,
157
- // since wiki may also be running under PM2)
156
+ // Function to stop PM2-managed allyabase services by name only.
157
+ // NEVER use "pm2 stop all" — that would kill wiki itself if it's running under PM2.
158
158
  async function stopPM2() {
159
159
  console.log('[wiki-plugin-allyabase] Stopping allyabase services...');
160
160
 
161
- return new Promise((resolve) => {
162
- exec('pm2 stop all', (err, stdout, stderr) => {
163
- if (err) {
164
- console.log(`[wiki-plugin-allyabase] pm2 stop all failed (might not be running): ${err.message}`);
165
- } else {
166
- console.log(`[wiki-plugin-allyabase] Allyabase services stopped`);
167
- }
161
+ const serviceNames = Object.keys(SERVICE_PORTS);
168
162
 
169
- // Clean up PID file
170
- cleanupPidFile();
171
- resolve();
172
- });
173
- });
163
+ await Promise.all(serviceNames.map(name =>
164
+ new Promise((resolve) => {
165
+ exec(`pm2 stop ${name}`, (err) => {
166
+ if (err) {
167
+ // Service wasn't running under PM2 — that's fine
168
+ } else {
169
+ console.log(`[wiki-plugin-allyabase] Stopped PM2 service: ${name}`);
170
+ }
171
+ resolve();
172
+ });
173
+ })
174
+ ));
175
+
176
+ console.log('[wiki-plugin-allyabase] Allyabase services stopped');
177
+ cleanupPidFile();
174
178
  }
175
179
 
176
180
  // Function to clean up orphaned processes from previous run