fix: add Windows compatibility for PM2 detection
- Use .cmd extension for PM2 on Windows (pm2.cmd vs pm2) - Add shell: true to execSync for proper path quoting on Windows 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -264,14 +264,18 @@ async function main() {
|
||||
// Try to start the PM2 worker after fresh install
|
||||
try {
|
||||
log('🚀 Starting worker service...', colors.cyan);
|
||||
const localPm2 = join(NODE_MODULES_PATH, '.bin', 'pm2');
|
||||
const pm2Command = existsSync(localPm2) ? localPm2 : 'pm2';
|
||||
// On Windows, PM2 executable is pm2.cmd, not pm2
|
||||
const localPm2Base = join(NODE_MODULES_PATH, '.bin', 'pm2');
|
||||
const localPm2Cmd = process.platform === 'win32' ? localPm2Base + '.cmd' : localPm2Base;
|
||||
const pm2Command = existsSync(localPm2Cmd) ? localPm2Cmd : 'pm2';
|
||||
const ecosystemPath = join(PLUGIN_ROOT, 'ecosystem.config.cjs');
|
||||
|
||||
// shell: true required for Windows to handle quoted paths correctly
|
||||
execSync(`"${pm2Command}" start "${ecosystemPath}"`, {
|
||||
cwd: PLUGIN_ROOT,
|
||||
stdio: 'pipe',
|
||||
encoding: 'utf-8'
|
||||
encoding: 'utf-8',
|
||||
shell: true
|
||||
});
|
||||
|
||||
log('✅ Worker service started', colors.green);
|
||||
|
||||
@@ -56,15 +56,19 @@ async function startWorker(): Promise<boolean> {
|
||||
}
|
||||
|
||||
// Try to use local PM2 from node_modules first, fall back to global PM2
|
||||
const localPm2 = path.join(pluginRoot, 'node_modules', '.bin', 'pm2');
|
||||
const pm2Command = existsSync(localPm2) ? localPm2 : 'pm2';
|
||||
// On Windows, PM2 executable is pm2.cmd, not pm2
|
||||
const localPm2Base = path.join(pluginRoot, 'node_modules', '.bin', 'pm2');
|
||||
const localPm2Cmd = process.platform === 'win32' ? localPm2Base + '.cmd' : localPm2Base;
|
||||
const pm2Command = existsSync(localPm2Cmd) ? localPm2Cmd : 'pm2';
|
||||
|
||||
// Start using PM2 with the ecosystem config
|
||||
// CRITICAL: Must set cwd to pluginRoot so PM2 starts from marketplace directory
|
||||
// shell: true required for Windows to handle quoted paths correctly
|
||||
execSync(`"${pm2Command}" start "${ecosystemPath}"`, {
|
||||
cwd: pluginRoot,
|
||||
stdio: 'pipe',
|
||||
encoding: 'utf-8'
|
||||
encoding: 'utf-8',
|
||||
shell: true
|
||||
});
|
||||
|
||||
// Wait for worker to become healthy
|
||||
|
||||
Reference in New Issue
Block a user