UNPKG

@heyukai/weather-server

Version:
24 lines (19 loc) 613 B
#!/usr/bin/env node const { spawn } = require('child_process'); const path = require('path'); // 1. 获取 Python 解释器路径 const pythonExecutable = process.platform === 'win32' ? 'python' : 'python3'; // 2. 设置 Python 脚本路径 const scriptPath = path.join(__dirname, '../src/server.py'); // 3. 启动 Python 进程 const pythonProcess = spawn(pythonExecutable, [scriptPath], { stdio: 'inherit' }); // 4. 处理退出信号 process.on('SIGINT', () => { pythonProcess.kill('SIGINT'); process.exit(); }); pythonProcess.on('close', (code) => { process.exit(code); });