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

Fix #296 Removed PM2 for daemon mode

parent 15015292
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env node
"use strict";
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")
});
switch (process.argv[2]) {
case "start":
daemon.start();
break;
case "stop":
daemon.stop();
break;
case "restart":
daemon.stop(function(err) {
err && console.error(err);
daemon.start();
});
break;
default:
console.log("Usage: [start|stop|restart]");
}
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
"co": "4.6.0", "co": "4.6.0",
"colors": "1.1.2", "colors": "1.1.2",
"commander": "2.1.0", "commander": "2.1.0",
"daemonize2": "0.4.2",
"event-stream": "3.1.5", "event-stream": "3.1.5",
"express": "3.4.7", "express": "3.4.7",
"express-cors": "0.0.3", "express-cors": "0.0.3",
...@@ -49,7 +50,6 @@ ...@@ -49,7 +50,6 @@
"naclb": "1.0.0", "naclb": "1.0.0",
"nnupnp": "1.0.1", "nnupnp": "1.0.1",
"optimist": "^0.6.1", "optimist": "^0.6.1",
"pm2": "0.15.10",
"q": "1.1.2", "q": "1.1.2",
"q-io": "1.13.2", "q-io": "1.13.2",
"request": "2.31.0", "request": "2.31.0",
......
...@@ -8,81 +8,43 @@ ...@@ -8,81 +8,43 @@
ucoind() { ucoind() {
local UCOIN_DATABASE
local UCOIN_LOG_FILE
local UCOIN_DATA_HOME
local NODE local NODE
local PM2
if [ -z "$DEV_MODE" ]; then
### Production mode
if [[ -d $UCOIN_DIR/node ]]; then if [[ -d $UCOIN_DIR/node ]]; then
NODE=$UCOIN_DIR/node/bin/node NODE=$UCOIN_DIR/node/bin/node
fi; fi;
VERSION=`$NODE -v`
if [[ $VERSION != v0.12* ]]; then
echo "$NODE v0.12 is required";
else else
# OK, execute command ### Cheating with DEV mode
PM2=$UCOIN_DIR/node_modules/pm2/bin/pm2 UCOIN_DIR=`pwd`
UCOIN_DATA_HOME=$HOME/.config/ucoin NODE=node
fi
case "$1" in
#--------------------------------- VERSION=`$NODE -v`
# UCOIN DAEMON MANAGEMENT: START
#---------------------------------
start) if [[ $VERSION != v4* ]]; then
local test echo "$NODE v4+ is required";
local UCOIN_LOG_FILE
local UCOIN_ERR_FILE
UCOIN_DATABASE=$2
if [ -z $UCOIN_DATABASE ]; then
UCOIN_DATABASE="$UCOIN_DB"
fi
if [ -z $UCOIN_DATABASE ]; then
UCOIN_DATABASE="ucoin_default"
fi
UCOIN_LOG_FILE=$UCOIN_DATA_HOME/$UCOIN_DATABASE/ucoin.log
UCOIN_ERR_FILE=$UCOIN_DATA_HOME/$UCOIN_DATABASE/ucoin.err.log
test=`$NODE $PM2 list | grep "$UCOIN_DATABASE.*online"`
if [ -z "$test" ]; then
echo $UCOIN_LOG_FILE
$NODE $PM2 start -f "$UCOIN_DIR/bin/ucoind" --name "$UCOIN_DATABASE" --interpreter="$NODE" --node-args="--harmony" --log $UCOIN_LOG_FILE --error $UCOIN_ERR_FILE --merge-logs -- start --mdb "$UCOIN_DATABASE" --httplogs 2>/dev/null
echo "uCoin with DB '$UCOIN_DATABASE' started. Use 'ucoind logs' to see interactive logs."
else else
echo 1>&2 "uCoin '$UCOIN_DATABASE' already started."
fi
;;
case "$1" in
#--------------------------------- #---------------------------------
# UCOIN DAEMON MANAGEMENT: STOP & OTHERS # UCOIN DAEMON MANAGEMENT
#--------------------------------- #---------------------------------
list|info|logs|stop|restart|monit|delete) start|stop|restart)
UCOIN_DATABASE=$2 $NODE --harmony "$UCOIN_DIR/bin/daemon" $*
if [ -z $UCOIN_DATABASE ]; then
UCOIN_DATABASE="$UCOIN_DB"
fi
if [ -z $UCOIN_DATABASE ]; then
UCOIN_DATABASE="ucoin_default"
fi
$NODE $PM2 $1 $UCOIN_DATABASE
;;
delete-all)
$NODE $PM2 delete all
;; ;;
#--------------------------------- #---------------------------------
# UCOIN NORMAL COMMANDS # UCOIN CLI COMMANDS
#--------------------------------- #---------------------------------
*) *)
$NODE --harmony "$UCOIN_DIR/bin/ucoind" --mdb "$UCOIN_DATABASE" $* $NODE --harmony "$UCOIN_DIR/bin/ucoind" $*
;; ;;
esac esac
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment