forked from stegripe/rawon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.js
31 lines (26 loc) · 1.06 KB
/
start.js
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
const { execSync } = require("child_process");
const http = require("http");
const isThisGlitch = (
process.env.PROJECT_DOMAIN !== undefined &&
process.env.PROJECT_INVITE_TOKEN !== undefined &&
process.env.API_SERVER_EXTERNAL !== undefined &&
process.env.PROJECT_REMIX_CHAIN !== undefined);
if (isThisGlitch) {
http.createServer((req, res) => {
const now = new Date().toLocaleString("en-US");
res.end(`OK (200) - ${now}`);
}).listen(process.env.PORT);
setInterval(() => {
http.get(`http://${process.env.PROJECT_DOMAIN}.glitch.me/`);
}, 280000);
}
start(isThisGlitch);
function start(glitch = false) {
if (glitch) {
console.info("[INFO] Glitch environment detected, trying to compile...");
execSync("npm run compile");
console.info("[INFO] Compiled, starting the bot...");
if (process.env.CONFIG_CACHE_YOUTUBE_DOWNLOADS === "yes") console.warn("[WARN] Using cache on Glitch environment is not recommended, it will eat the project storage drastically.");
}
require("./dist/main.js");
}