Initial commit
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import proc, { exec, execSync } from 'child_process'
|
||||
import { ConsoleCommandData } from '../types/Command';
|
||||
import { server } from '..';
|
||||
import { db } from '../util/database';
|
||||
|
||||
export const metadata: ConsoleCommandData = {
|
||||
name: 'restart',
|
||||
description: "Restarts the application.",
|
||||
usage: false,
|
||||
aliases: ["re", "reboot"]
|
||||
}
|
||||
|
||||
|
||||
export function run(command: string) {
|
||||
try {
|
||||
execSync(command, { stdio: 'inherit' })
|
||||
} catch (err) {
|
||||
//c.error(`Caught exception while rebuilding the project. E:\n${err}`)
|
||||
process.exit(0) // probably a sigint?
|
||||
}
|
||||
}
|
||||
|
||||
export function Main(args: Array<string>): string {
|
||||
try {
|
||||
server.close();
|
||||
db.close();
|
||||
} catch { } // if this fails then the server and db are probably closed already
|
||||
|
||||
run("npm run quick");
|
||||
|
||||
return "The new process has crashed. Run \"restart\" to rebuild the application again."
|
||||
}
|
||||
Reference in New Issue
Block a user