From fe96625dc977b2f5c409d92d585d6b73540be10e Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 29 Sep 2018 14:26:59 -0700 Subject: [PATCH] bin: add --daemon-log option. --- bin/hsd | 19 ++++++++++++++++--- bin/hsw | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/bin/hsd b/bin/hsd index 5f478501..f9059ffb 100755 --- a/bin/hsd +++ b/bin/hsd @@ -3,10 +3,12 @@ rl=0 daemon=0 cmd='node' +log='/dev/null' +next=0 if ! type perl > /dev/null 2>& 1; then if uname | grep -i 'darwin' > /dev/null; then - echo 'HSK requires perl to start on OSX.' >& 2 + echo 'hsd requires perl to start on OSX.' >& 2 exit 1 fi rl=1 @@ -39,10 +41,21 @@ if test x"$1" = x'rpc'; then fi for arg in "$@"; do + if test $next -eq 1; then + log="$arg" + next=0 + fi case "$arg" in --daemon) daemon=1 ;; + --daemon-log) + next=1 + ;; + --daemon-log=*) + log=$(echo "$arg" | sed 's/^--daemon-log=//g') + log="${log/#\~/$HOME}" + ;; --spv) cmd='spvnode' ;; @@ -53,13 +66,13 @@ if test $daemon -eq 1; then # And yet again, OSX doesn't support something. if ! type setsid > /dev/null 2>& 1; then ( - "${dir}/${cmd}" "$@" > /dev/null 2>& 1 & + "${dir}/${cmd}" "$@" > "$log" 2>& 1 & echo "$!" ) exit 0 fi ( - setsid "${dir}/${cmd}" "$@" > /dev/null 2>& 1 & + setsid "${dir}/${cmd}" "$@" > "$log" 2>& 1 & echo "$!" ) exit 0 diff --git a/bin/hsw b/bin/hsw index 6a56b2f2..73bb4b31 100755 --- a/bin/hsw +++ b/bin/hsw @@ -5,7 +5,7 @@ daemon=0 if ! type perl > /dev/null 2>& 1; then if uname | grep -i 'darwin' > /dev/null; then - echo 'HSK requires perl to start on OSX.' >& 2 + echo 'hsw requires perl to start on OSX.' >& 2 exit 1 fi rl=1