Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Commit

Permalink
[issue 1066]: enhance service script to return version information fo…
Browse files Browse the repository at this point in the history
…r '-v' option (#520)

* [issue 1066]: enhance service script to return version information for '-v' option

* [issue 1066]: address review comments

Co-authored-by: Yee <2520865+yixinglu@users.noreply.github.com>
  • Loading branch information
jtcheng and yixinglu authored Jul 14, 2021
1 parent b848eea commit 79e03de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/nebula.service
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ function kill_daemon {
# args: <daemon name> [config file]
function status_daemon {
local daemon_name=nebula-${1}
local daemon_version=$(daemon_version ${INSTALL_ROOT}/bin/${daemon_name})
local config=${2}

[[ -z ${config} ]] && config=${INSTALL_ROOT}/etc/${daemon_name}.conf
Expand All @@ -221,9 +222,9 @@ function status_daemon {
else
port=${BLINK}${RED}${port}${NC}
fi
INFO "${daemon_name}: Running as $(cat ${pid_file}), Listening on ${port}"
INFO "${daemon_name}(${daemon_version}): Running as $(cat ${pid_file}), Listening on ${port}"
else
INFO "${daemon_name}: Exited"
INFO "${daemon_name}(${daemon_version}): Exited"
fi
}

Expand Down
7 changes: 7 additions & 0 deletions scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,10 @@ function env_check {
WARN "The CPU time a process can consume is restricted to ${cputime}"
fi
}

# Get the daemon Git commit version information
function daemon_version {
local version=$(${1} --version | head -n 1)
echo ${version} | sed 's/.*Git: \([[:alnum:]]*\).*/\1/g'
}

0 comments on commit 79e03de

Please sign in to comment.