-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
34 lines (29 loc) · 796 Bytes
/
index.js
File metadata and controls
34 lines (29 loc) · 796 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
/** @format */
const fs = require( "fs" );
const path = require( "path" );
const childProcesses = require( "node:child_process" );
const Logger = require( "./botlog" );
const spawnBot = ( code, startup ) =>
{
if ( !startup )
{
if ( code )
Logger.error( `Process had closed with code: ${ code }. Restarting now.` );
else Logger.error( `Process had closed. Restarting now.` );
}
return childProcesses.fork(
"./clientstart",
[ startup ? process.argv[ 2 ] ?? `` : `` ],
{
stdio: "pipe",
}
);
};
( async () =>
{
console.log( "Starting bot..." );
const mainBotProcess = spawnBot( null, true );
mainBotProcess.stdout?.on( "data", Logger.log );
mainBotProcess.stderr?.on( "data", Logger.error );
mainBotProcess.on( "close", spawnBot );
} )();