File size: 662 Bytes
3dff952
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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}`);
});