MCPcopy Create free account
hub / github.com/GlobalTechInfo/MEGA-MD / restartProcess

Function restartProcess

plugins/update.js:183–214  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

181 return { copiedFiles: copied };
182}
183async function restartProcess() {
184 // Check if running in Docker
185 try {
186 const { existsSync } = await import('fs');
187 if (existsSync('/.dockerenv')) {
188 setTimeout(() => process.exit(1), 500);
189 return;
190 }
191 }
192 catch { }
193 // Try pm2 first
194 try {
195 await run('pm2 restart all');
196 return;
197 }
198 catch { }
199 // Spawn new process (VPS/bare metal)
200 try {
201 const { spawn } = await import('child_process');
202 const child = spawn(process.execPath, process.argv.slice(1), {
203 detached: true,
204 stdio: 'ignore',
205 cwd: process.cwd(),
206 env: process.env
207 });
208 child.unref();
209 setTimeout(() => process.exit(0), 1500);
210 return;
211 }
212 catch { }
213 setTimeout(() => process.exit(0), 500);
214}
215export default {
216 command: 'update',
217 aliases: ['upgrade', 'restart'],

Callers 1

handlerFunction · 0.85

Calls 1

runFunction · 0.85

Tested by

no test coverage detected