summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorskydrome2015-07-21 10:19:30 -0400
committerskydrome2015-07-21 10:19:30 -0400
commitfffd140d472944beb65df011ae79e46f809a9f67 (patch)
tree77afc6c5ad8a60186e404d96bcdd252851e001f3
parente33a5298f78baddce963e60a63f543d9f01d582d (diff)
downloadaur-fffd140d472944beb65df011ae79e46f809a9f67.tar.gz
fix stopping freenet
-rw-r--r--freenet.service4
-rw-r--r--run.sh58
2 files changed, 26 insertions, 36 deletions
diff --git a/freenet.service b/freenet.service
index 0f2f2ffcff3e..23db0fb1d7d4 100644
--- a/freenet.service
+++ b/freenet.service
@@ -5,8 +5,8 @@ After=network.target
[Service]
Type=forking
User=freenet
-ExecStart=/opt/freenet/run.sh start
-ExecStop=/opt/freenet/run.sh stop
+ExecStart=/opt/freenet/run.sh start --quiet
+ExecStop=/opt/freenet/run.sh stop --quiet
WorkingDirectory=/opt/freenet
[Install]
diff --git a/run.sh b/run.sh
index 97acd33c82fa..75b38c506237 100644
--- a/run.sh
+++ b/run.sh
@@ -50,7 +50,6 @@ check_if_running() {
if [[ -f "$PIDFILE" ]]; then
if [[ -r "$PIDFILE" ]]; then
pid=$(cat "$PIDFILE")
- #echo "debug: pid:$pid get_pid:$(get_pid)"
if [[ ! "$pid" ]]; then
pid=$(get_pid)
if [[ ! "$pid" ]]; then
@@ -84,12 +83,14 @@ _start() {
eval $COMMAND_LINE
[[ $? != 0 ]] && fail "Failed to launch the wrapper!"
i=0
- while [[ ! "$pid" || $i < $TIMEOUT ]]; do
- echo -n "."
- sleep 1
- check_if_running
- ((i++))
- done
+ if [[ ! $_quiet ]]; then
+ while [[ ! "$pid" || $i < $TIMEOUT ]]; do
+ echo -n "."
+ sleep 1
+ check_if_running
+ ((i++))
+ done
+ fi
[[ $(get_pid) ]] &&
echo " done" || fail "timeout: Failed to start wrapper!"
else
@@ -105,31 +106,21 @@ _restart() {
_stop() {
if [[ "$pid" ]]; then
echo -n "Stopping Freenet"
- kill -TERM $pid
+ kill -TERM $(get_wrapper_pid)
[[ $? != 0 ]] && fail "Unable to stop Freenet: kill -TERM $pid"
i=0
- while [[ "$pid" || $i > $TIMEOUT ]]; do
- echo -n "."
- sleep 1
- [[ ! $(get_pid) ]] && unset pid
- ((i++))
- done
- if [[ "$pid" ]]; then
- fail "timeout: Failed to stop wrapper!"
- else
- echo " done"
- [[ "$1" = 'start' ]] && _start
+ if [[ ! $_quiet ]]; then
+ while [[ "$pid" || $i > $TIMEOUT ]]; do
+ echo -n "."
+ sleep 1
+ [[ ! $(get_pid) ]] && unset pid
+ ((i++))
+ done
+ if [[ "$pid" ]]; then
+ fail "timeout: Failed to stop wrapper!"
+ fi
fi
- else
- echo "Freenet is not running."
- fi
-}
-
-_graceful() {
- if [[ "$pid" ]]; then
- echo "Stopping Freenet gracefully..."
- kill -HUP $pid
- [[ $? != 0 ]] && fail "Unable to stop Freenet."
+ echo " done"
else
echo "Freenet is not running."
fi
@@ -152,10 +143,13 @@ _dump() {
}
#-----------------------------------------------------------------------------
-check_user "$@"
+check_user "$*"
init_vars
check_if_running
+[[ "$2" = '--quiet' ]] &&
+ _quiet=true
+
case "$1" in
'console') _console
;;
@@ -163,8 +157,6 @@ case "$1" in
;;
'stop') _stop
;;
- 'graceful') _graceful
- ;;
'restart') _restart
;;
'status') _status
@@ -178,7 +170,6 @@ case "$1" in
echo " console Launch in the current console"
echo " start Start in the background as a daemon process"
echo " stop Stop if running as a daemon or in another console"
- echo " graceful Stop gracefully, may take up to 11 minutes for all tunnels to close"
echo " restart Restart the JVM"
echo " status Query the current status"
echo " dump Request a Java thread dump if running"
@@ -186,4 +177,3 @@ case "$1" in
;;
esac
exit 0
-