Skip to content
Snippets Groups Projects
Commit 94fe97fd authored by Cédric Moreau's avatar Cédric Moreau
Browse files

Added `webstart`, `webstop` and `webrestart` utility commands.

parent d373aebf
No related branches found
No related tags found
No related merge requests found
......@@ -4,11 +4,7 @@
var directory = require('../app/lib/directory');
var path = require('path');
var daemon = require("daemonize2").setup({
main: "ucoind",
name: directory.INSTANCE_NAME,
pidfile: path.join(directory.INSTANCE_HOME, "app.pid")
});
var daemon = getDaemon('start');
switch (process.argv[2]) {
......@@ -21,15 +17,25 @@ switch (process.argv[2]) {
break;
case "restart":
daemon = require("daemonize2").setup({
main: "ucoind",
name: directory.INSTANCE_NAME,
pidfile: path.join(directory.INSTANCE_HOME, "app.pid"),
// We must redefine the main argument to 'start' because uCoin will receive it as command argument and does not
// know about 'restart' command.
argv: process.argv.slice(2).map((arg, index) => index == 0 ? 'start' : arg)
daemon = getDaemon('start');
daemon.stop(function(err) {
err && console.error(err);
daemon.start();
});
break;
case "webstart":
daemon = getDaemon('webstart');
daemon.start();
break;
case "webstop":
daemon = getDaemon('webstart');
daemon.stop();
break;
case "webrestart":
daemon = getDaemon('webstart');
daemon.stop(function(err) {
err && console.error(err);
daemon.start();
......@@ -42,5 +48,17 @@ switch (process.argv[2]) {
break;
default:
console.log("Usage: [start|stop|restart]");
console.log("Usage: [webstart|webstop|webrestart|start|stop|restart]");
}
function getDaemon(overrideCommand) {
return require("daemonize2").setup({
main: "ucoind",
name: directory.INSTANCE_NAME,
pidfile: path.join(directory.INSTANCE_HOME, "app.pid"),
// We must redefine the main argument to 'start' because uCoin will receive it as command argument and does not
// know about 'restart' command.
argv: process.argv.slice(2).map((arg, index) => index == 0 && overrideCommand ? overrideCommand : arg)
});
}
......@@ -39,7 +39,7 @@ duniter() {
# UCOIN DAEMON MANAGEMENT
#---------------------------------
start|stop|restart)
webstart|webstop|webrestart|start|stop|restart)
$NODE "$DUNITER_DIR/bin/daemon" $*
;;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment