-
Notifications
You must be signed in to change notification settings - Fork 4
/
server.js
39 lines (32 loc) · 1.05 KB
/
server.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
32
33
34
35
36
37
38
39
import dotenv from "dotenv";
dotenv.config();
import findRemoveSync from "find-remove";
import app from "./app.js";
import loadBots from "./modules/load-bots.js";
import checkBotPool from "./modules/check-bot-pool.js";
import { dirname } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
console.log(process.env);
(async () => {
const bots = await loadBots(app);
app.set("bots", bots);
setInterval(() => {
console.log("deleting old temporary files...");
const result = findRemoveSync(__dirname + "/temp", {
files: "*.*",
age: {
seconds: 3600,
},
});
console.log(result);
}, 60000);
const listener = app.listen(process.env.PORT || 3000, async () => {
checkBotPool(app);
// const bots = await loadBots(app);
// app.set("bots", bots);
// console.log('bots', bots.map(bot => bot.about.name));
console.log(`🖥️ running on port ${listener.address().port}`);
console.log(`🕒 server time: ${new Date().toTimeString()}`);
});
})();