-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.ts
More file actions
39 lines (33 loc) · 982 Bytes
/
server.ts
File metadata and controls
39 lines (33 loc) · 982 Bytes
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
33
34
35
36
37
38
39
import express from "express";
import { execSync } from "child_process";
import path from "path";
import "dotenv/config";
const app = express();
const port = 3001;
app.get("/status", (req, res) => {
res.send("Server is running!");
});
app.get("/deploy", (req, res) => {
const env = req.query.env || "dev";
const scriptPath = path.join(__dirname, "../deploy_vm.sh");
execSync(`bash ${scriptPath} ${env} ${process.env.REPO_URL}`, {
stdio: "inherit",
});
res.send("Finished!");
// const command = spawn(`bash ${scriptPath} ${env} ${process.env.REPO_URL}`);
// command.stdout.on("data", (data) => {
// res.write(data);
// });
// command.stderr.on("data", (data) => {
// res.write(data);
// });
// command.on("error", (err) => {
// res.end(err.message);
// });
// command.on("exit", (code) => {
// res.end(`Finished with code: ${code}!`);
// });
});
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});