-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevelopment.js
61 lines (59 loc) · 1.63 KB
/
development.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
'use strict';
process.stdin.setEncoding('utf8');
process.stdin.on('data', async input => {
try {
let t = eval(input.toString().trim());
if (t instanceof Promise) console.log(await t);
else console.log(t);
} catch (e) {
console.warn(e);
}
});
process.on('restart', async () => {
console.log('Signal detected, restarting...');
await global.Hydro.stop();
await global.Hydro.destory();
delete global.Hydro;
delete require.cache;
run();
});
async function run() {
const hydro = require('hydro-framework');
let config;
try {
config = require('./config.js');
config.middleware = [
hydro.handler.trace,
hydro.handler.nunjucks,
hydro.handler.log,
hydro.handler.base,
hydro.handler.user
];
config.hosts = {
'osu.sh': [
require('./handler/main/main.js')
],
'bbs.osu.sh': [
require('./handler/bbs/message.js'),
require('./handler/bbs/main.js')
]
};
config.perm = require('./permission.js');
config.constants = {
MODE_NAME: ['osu!', 'osu!taiko', 'osu!catch', 'osu!mania']
};
} catch (e) {
console.error('Error loading application:');
console.error(e);
process.exit(1);
}
global.Hydro = new hydro.app(config);
await global.Hydro.load().catch(e => {
console.error('Error loading application:');
console.error(e);
});
await global.Hydro.listen().catch(e => {
console.error(e);
});
}
run();