| |
| |
| |
| |
| |
|
|
| const fs = require('fs'); |
| const path = require('path'); |
| const { spawn } = require('child_process'); |
|
|
| console.log('===== Minimal Stremio Server Starter ====='); |
|
|
| |
| const searchPaths = [ |
| '/srv/stremio-server', |
| '/app', |
| '/usr/lib/node_modules/stremio-server', |
| '/opt/stremio' |
| ]; |
|
|
| |
| const findServerJs = () => { |
| for (const basePath of searchPaths) { |
| const serverPath = path.join(basePath, 'server.js'); |
| try { |
| if (fs.existsSync(serverPath)) { |
| console.log(`Found server.js at: ${serverPath}`); |
| return serverPath; |
| } |
| } catch (e) { |
| console.log(`Error checking ${serverPath}: ${e.message}`); |
| } |
| } |
| |
| |
| try { |
| const { execSync } = require('child_process'); |
| const result = execSync('find / -name server.js 2>/dev/null | grep stremio').toString().trim(); |
| if (result) { |
| console.log(`Found server.js using find: ${result}`); |
| return result.split('\n')[0]; |
| } |
| } catch (e) { |
| console.log(`Error using find: ${e.message}`); |
| } |
| |
| return null; |
| }; |
|
|
| const serverJsPath = findServerJs(); |
|
|
| if (!serverJsPath) { |
| console.error('Could not find server.js'); |
| process.exit(1); |
| } |
|
|
| |
| console.log(`Starting Stremio server with Node...`); |
|
|
| const nodeArgs = [serverJsPath]; |
| const stremioServer = spawn('node', nodeArgs, { |
| stdio: 'inherit', |
| env: { |
| ...process.env, |
| NO_CORS: '1', |
| CASTING_DISABLED: '1', |
| STREMIO_LOGGING: '1', |
| APP_PATH: process.env.APP_PATH || '/tmp/.stremio-server' |
| } |
| }); |
|
|
| stremioServer.on('close', (code) => { |
| console.log(`Stremio server exited with code ${code}`); |
| process.exit(code); |
| }); |
|
|
| process.on('SIGINT', () => { |
| console.log('Received SIGINT, shutting down...'); |
| stremioServer.kill('SIGINT'); |
| }); |
|
|
| process.on('SIGTERM', () => { |
| console.log('Received SIGTERM, shutting down...'); |
| stremioServer.kill('SIGTERM'); |
| }); |