forked from hobbyquaker/homematic-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hm-manager.js
executable file
·47 lines (38 loc) · 877 Bytes
/
hm-manager.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
/**
* homematic-manager
*
* Copyright (c) 2014 Anli, Hobbyquaker
*
* CC BY-NC-SA 4.0 (http://creativecommons.org/licenses/by-nc-sa/4.0/)
*
*/
var daemon = require("daemonize2").setup({
main: "main.js",
name: "hm-manager",
pidfile: "hm-manager.pid"
});
switch (process.argv[2]) {
case "start":
daemon.start();
break;
case "stop":
daemon.stop();
break;
case "kill":
daemon.kill();
break;
case "restart":
daemon.stop(function(err) {
daemon.start();
});
break;
case "status":
var pid = daemon.status();
if (pid)
console.log("Daemon running. PID: " + pid);
else
console.log("Daemon is not running.");
break;
default:
console.log("Usage: [start|stop|kill|restart|status]");
}