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

Fix #247 ucoind now behaves as a daemon process

parent fdca7fd1
Branches
Tags
No related merge requests found
......@@ -48,6 +48,7 @@
"multimeter": "0.1.1",
"naclb": "0.2.2",
"nat-upnp": "https://github.com/c-geek/node-nat-upnp",
"pm2": "0.15.10",
"q": "1.1.2",
"q-io": "1.13.1",
"request": "2.31.0",
......
......@@ -8,7 +8,11 @@
ucoind() {
NODE=node
local UCOIN_DATABASE
local UCOIN_LOG_FILE
local UCOIN_DATA_HOME
local NODE
local PM2
if [[ -d $UCOIN_DIR/node ]]; then
NODE=$UCOIN_DIR/node/bin/node
......@@ -17,8 +21,71 @@ ucoind() {
VERSION=`$NODE -v`
if [[ $VERSION != v0.12* ]]; then
echo "Node.js v0.12 is not available";
echo "$NODE v0.12 is required";
else
$NODE --harmony $UCOIN_DIR/bin/ucoind $*
# OK, execute command
PM2=$UCOIN_DIR/node_modules/pm2/bin/pm2
UCOIN_DATA_HOME=$HOME/.config/ucoin
case "$1" in
#---------------------------------
# UCOIN DAEMON MANAGEMENT: START
#---------------------------------
start)
local test
local UCOIN_LOG_FILE
local UCOIN_ERR_FILE
UCOIN_LOG_FILE=$UCOIN_DATA_HOME/$UCOIN_DATABASE/ucoin.log
UCOIN_ERR_FILE=$UCOIN_DATA_HOME/$UCOIN_DATABASE/ucoin.err.log
if [ -z $UCOIN_DATABASE ]; then
UCOIN_DATABASE="ucoin_default"
fi
test=`$PM2 list | grep "$UCOIN_DATABASE.*online"`
if [ -z "$test" ]; then
echo $UCOIN_LOG_FILE
$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
echo 1>&2 "uCoin '$UCOIN_DATABASE' already started."
fi
;;
#---------------------------------
# UCOIN DAEMON MANAGEMENT: STOP & OTHERS
#---------------------------------
list|info|logs|stop|restart|monit|delete)
UCOIN_DATABASE=$2
if [ -z $UCOIN_DATABASE ]; then
UCOIN_DATABASE="$UCOIN_DB"
fi
if [ -z $UCOIN_DATABASE ]; then
UCOIN_DATABASE="ucoin_default"
fi
$PM2 $1 $UCOIN_DATABASE
;;
delete-all)
$PM2 delete all
;;
#---------------------------------
# UCOIN NORMAL COMMANDS
#---------------------------------
*)
$NODE --harmony "$UCOIN_DIR/bin/ucoind" --mdb "$UCOIN_DATABASE" $*
;;
esac
fi;
}
# If the script was launched with parameters, try to launch the uCoin command
if [ ! -z $1 ]; then
ucoind $*
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment