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