| const express = require("express"); |
| const { spawn } = require("child_process"); |
| const path = require("path"); |
|
|
| const app = express(); |
|
|
| |
| const botDirectory = path.join(__dirname, "bot"); |
|
|
| |
| const botProcess = spawn("node", ["app.js"], { cwd: botDirectory, stdio: "inherit" }); |
|
|
| app.get("/", (req, res) => { |
| res.send("hello"); |
| }); |
|
|
| |
| const PORT = 7860; |
| const server = app.listen(PORT, "0.0.0.0", () => { |
| console.log(`Server running on http://0.0.0.0:${PORT}`); |
| }); |
|
|
| |
| process.on("SIGINT", () => { |
| console.log("Shutting down..."); |
| botProcess.kill(); |
| server.close(() => process.exit(0)); |
| }); |