-
-
Notifications
You must be signed in to change notification settings - Fork 342
/
Copy pathindex.js
61 lines (58 loc) · 1.99 KB
/
index.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
if (process.argv.includes('--server')) require('./server')
require('dotenv').config(), require('rootpath')(), console.clear()
const { spawn: spawn } = require('child_process'), { Function: Func } = new(require('@neoxr/wb')), path = require('path'), colors = require('@colors/colors/safe'), CFonts = require('cfonts'), chalk = require('chalk')
const unhandledRejections = new Map()
process.on('uncaughtException', (err) => {
if (err.code === 'ENOMEM') {
console.error('Out of memory error detected. Cleaning up resources...');
// Lakukan tindakan pemulihan seperti membersihkan cache atau log
} else {
console.error('Uncaught Exception:', err)
}
})
process.on('unhandledRejection', (reason, promise) => {
unhandledRejections.set(promise, reason)
if (reason.code === 'ENOMEM') {
console.error('Out of memory error detected. Attempting recovery...');
Object.keys(require.cache).forEach((key) => {
delete require.cache[key]
})
} else {
console.log('Unhandled Rejection at:', promise, 'reason:', reason)
}
})
process.on('rejectionHandled', (promise) => {
unhandledRejections.delete(promise)
})
process.on('Something went wrong', function (err) {
console.log('Caught exception: ', err)
})
process.on('warning', (warning) => {
if (warning.name === 'MaxListenersExceededWarning') {
console.warn('Potential memory leak detected:', warning.message)
}
})
function start() {
let args = [path.join(__dirname, 'client.js'), ...process.argv.slice(2)]
let p = spawn(process.argv[0], args, { stdio: ['inherit', 'inherit', 'inherit', 'ipc'] })
.on('message', data => {
if (data == 'reset') {
console.log('Restarting...')
p.kill()
delete p
}
})
.on('exit', code => {
console.error('Exited with code:', code)
start()
})
}
CFonts.say('NEOXR BOT', {
font: 'tiny',
align: 'center',
colors: ['system']
}), CFonts.say('Github : https://github.com/neoxr/neoxr-bot', {
colors: ['system'],
font: 'console',
align: 'center'
}), start()