forked from hexparrot/mineos-node
-
Notifications
You must be signed in to change notification settings - Fork 3
/
service.js
35 lines (32 loc) · 772 Bytes
/
service.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
#!/usr/bin/env node
var daemon = require("daemonize2").setup({
main: "webui.js",
name: "mineos",
pidfile: "/var/run/mineos.pid"
});
if (process.getuid() != 0) {
console.log("Expected to run as root");
process.exit(1);
}
switch (process.argv[2]) {
case "start":
daemon.start();
break;
case "stop":
daemon.stop();
break;
case "restart":
daemon.stop(function(err) {
daemon.start();
});
break;
case "status":
var pid = daemon.status();
if (pid)
console.log("MineOS running. PID: " + pid);
else
console.log("MineOS is not running.");
break;
default:
console.log("Usage: [start|stop|restart|status]");
}