From b56ea74059b1da452fae245d162ef690cebc8bf9 Mon Sep 17 00:00:00 2001
From: cgeek <cem.moreau@gmail.com>
Date: Tue, 12 Jan 2016 18:30:40 +0100
Subject: [PATCH] Fix #304 Restart was not working

---
 bin/daemon | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/bin/daemon b/bin/daemon
index 5450dab4d..ea0c56fe8 100755
--- a/bin/daemon
+++ b/bin/daemon
@@ -4,8 +4,6 @@
 var directory = require('../app/lib/directory');
 var path = require('path');
 var Tail = require('always-tail');
-var fs = require('fs');
-var util = require('util');
 
 var daemon = require("daemonize2").setup({
   main: "ucoind",
@@ -34,6 +32,15 @@ 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.stop(function(err) {
       err && console.error(err);
       daemon.start();
-- 
GitLab