JDownloader Community - Appwork GmbH
 

Go Back   JDownloader Community - Appwork GmbH > International Support > JDownloader 2
Reply
 
Thread Tools Display Modes
  #1  
Old 26.08.2019, 14:48
Snake1980 Snake1980 is offline
Baby Loader
 
Join Date: Sep 2017
Location: Italy
Posts: 8
Default Jdownloader2 headless service fails to stop

I have a JDownloader2 headless installation on a Raspberry Pi 3 with Debian Buster installation.
On Debian Stretch it worked fine, but now, on Buster when I try to shutdown the service, JAVA process still running and JDownloader status became...

Code:
Aug 26 14:30:37 snakeberry systemd[1]: Stopping LSB: jDownloader2 Server Daemon...
Aug 26 14:30:37 snakeberry jdownloader[8039]: Stopping daemon: jDownloader2 Server start-stop-daemon: matching only on non-root pidfile /home/pi/jdownloader2/JDownlo
Aug 26 14:30:37 snakeberry systemd[1]: jdownloader.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
Aug 26 14:30:37 snakeberry systemd[1]: jdownloader.service: Failed with result 'exit-code'.
Aug 26 14:30:37 snakeberry systemd[1]: Stopped LSB: jDownloader2 Server Daemon.
This is my downloader2.service under /etc/init.d/ directory

Code:
#! /bin/sh
# /etc/init.d/jdownloader
### BEGIN INIT INFO
# Provides: jDownloader2
# Required-Start: networking
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: jDownloader2 Server Daemon
# Description: T_Send's Starts/Stops/Restarts/Status the jDownloader2 Server Daemon
### END INIT INFO
# Author: T_Send  Contact: t_send@itnu.pl  Web: www.itnu.pl

set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="jDownloader2 Server"
NAME="jdownloader"
## USER for new files ownership & make sure USER has read/write permission to DOWNLOAD-DIR
USER=pi
GROUP=pi
UMASK=077
DIR="/home/pi/jdownloader2"
SCRIPT="/etc/init.d/$NAME"
PIDFILE="$DIR/JDownloader.pid"
JAVA="/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/bin/java"
PARM="-Djava.awt.headless=true -jar $DIR/JDownloader.jar"
STATUS="$JAVA $PARM"

. /lib/lsb/init-functions

start_daemon () {
        start-stop-daemon --start \
                        --chuid $USER \
                        --group $GROUP \
                        --umask $UMASK \
                        --oknodo \
                        --background \
                        --make-pidfile --pidfile $PIDFILE \
                        --exec $JAVA -- $PARM
                log_end_msg $?
}

case "$1" in
    start)
        log_daemon_msg "Starting daemon" "$DESC "
        start_daemon
        ;;
    stop)
        log_daemon_msg "Stopping daemon" "$DESC "
        start-stop-daemon --stop \
            --pidfile $PIDFILE
        log_end_msg $?
        ;;
    restart)
        log_daemon_msg "Restarting daemon" "$DESC "
        start-stop-daemon --stop
            log_end_msg $?
        start_daemon
        ;;
    status)
        status_of_proc "$STATUS" "$DESC " && exit 0 || exit $?
        ;;
    *)
        log_action_msg "Usage: $SCRIPT {start|stop|restart|status}" || true
        exit 2
        ;;
esac

exit 0
Any suggestion?

Thanks
Reply With Quote
  #2  
Old 26.08.2019, 17:15
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,554
Default

do NOT use
Quote:
--make-pidfile --pidfile $PIDFILE
JDownloader will auto create pid file JDownloader.pid in JDownloader folder.

The pid may change during runtime (eg restart via webinterface or installation of updates).


Quote:
Control process exited, code=exited
sounds like the original/first PID is no longer valid because of listed reasons
__________________
JD-Dev & Server-Admin
Reply With Quote
  #3  
Old 26.08.2019, 17:16
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,554
Default

also add a sleep to restart command as JDownloader might install updates on shutdown and then restart might take some time
__________________
JD-Dev & Server-Admin
Reply With Quote
  #4  
Old 26.08.2019, 23:49
Snake1980 Snake1980 is offline
Baby Loader
 
Join Date: Sep 2017
Location: Italy
Posts: 8
Default

Modified (without sleep for now) and I removed PIDFILE...

Code:
#! /bin/sh
# /etc/init.d/jdownloader
### BEGIN INIT INFO
# Provides: jDownloader2
# Required-Start: networking
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: jDownloader2 Server Daemon
# Description: T_Send's Starts/Stops/Restarts/Status the jDownloader2 Server Daemon
### END INIT INFO
# Author: T_Send  Contact: t_send@itnu.pl  Web: www.itnu.pl

set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="jDownloader2 Server"
NAME="jdownloader"
## USER for new files ownership & make sure USER has read/write permission to DOWNLOAD-DIR
USER=pi
GROUP=pi
UMASK=077
DIR="/home/pi/jdownloader2"
SCRIPT="/etc/init.d/$NAME"
#PIDFILE="$DIR/JDownloader.pid"
JAVA="/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/jre/bin/java"
PARM="-Djava.awt.headless=true -jar $DIR/JDownloader.jar"
STATUS="$JAVA $PARM"

. /lib/lsb/init-functions

start_daemon () {
        start-stop-daemon --start \
			--chuid $USER \
                        --group $GROUP \
                        --umask $UMASK \
			--oknodo \
			--background \
			--exec $JAVA -- $PARM
		log_end_msg $?
}

case "$1" in
    start)
        log_daemon_msg "Starting daemon" "$DESC "
        start_daemon
        ;;
    stop)
        log_daemon_msg "Stopping daemon" "$DESC "
        start-stop-daemon --stop
        log_end_msg $?
        ;;
    restart)
        log_daemon_msg "Restarting daemon" "$DESC "
        start-stop-daemon --stop
        log_end_msg $?
        start_daemon
        ;;
    status)
        status_of_proc "$STATUS" "$DESC " && exit 0 || exit $?
        ;;
    *)
        log_action_msg "Usage: $SCRIPT {start|stop|restart|status}" || true
        exit 2
        ;;
esac

exit 0
but when I shutdown...


Code:
Aug 26 23:48:03 snakeberry jdownloader[22983]: Stopping daemon: jDownloader2 Server start-stop-daemon: need at least one of -
Aug 26 23:48:03 snakeberry jdownloader[22983]: Try 'start-stop-daemon --help' for more information.
Aug 26 23:48:03 snakeberry systemd[1]: jdownloader.service: Control process exited, code=exited, status=3/NOTIMPLEMENTED
Aug 26 23:48:03 snakeberry systemd[1]: jdownloader.service: Failed with result 'exit-code'.
Aug 26 23:48:03 snakeberry systemd[1]: Stopped LSB: jDownloader2 Server Daemon.
Reply With Quote
  #5  
Old 27.08.2019, 11:44
Snake1980 Snake1980 is offline
Baby Loader
 
Join Date: Sep 2017
Location: Italy
Posts: 8
Default

Solved, but not with your solution.

First...No need to remove --make-pidfile. It works also after an autorestart after upgrade.

Second...On buster something changed...

Code:
Aug 27 11:30:58 snakeberry jdownloader[26565]: Stopping daemon: jDownloader2 Server start-stop-daemon: matching only on non-root pidfile /home/pi/jdownloader2/JDownloader.pid is is insecure
Aug 27 11:30:58 snakeberry systemd[1]: jdownloader.service: Control process exited, code=exited, status=2/INVALIDARGUMENT
Aug 27 11:30:58 snakeberry systemd[1]: jdownloader.service: Failed with result 'exit-code'.
Aug 27 11:30:58 snakeberry systemd[1]: Stopped LSB: jDownloader2 Server Daemon.
The error message "Server start-stop-daemon: matching only on non-root pidfile /home/pi/jdownloader2/JDownloader.pid is is insecure" is the key

I can solve this by passing --exec and/or --user to stop command (I added just --user)...

Code:
    stop)
        log_daemon_msg "Stopping daemon" "$DESC "
        start-stop-daemon --stop \
        --pidfile $PIDFILE \
        --user $USER
        log_end_msg $?
        ;;

Now...service stops without problems.

I hope this can helps

Last edited by Snake1980; 27.08.2019 at 11:59.
Reply With Quote
  #6  
Old 27.08.2019, 14:16
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,554
Default

I did mean to remove "--make-pidfile" as JDownloader creates this file automatically. In Stop it's still required to know the correct/current PID of the process.

Also you should still add a sleep in restart command as the current script doesn't give enough time for JDownloader to install pending updates


Thanks for your feedback and sharing your script!
__________________
JD-Dev & Server-Admin
Reply With Quote
  #7  
Old 27.08.2019, 14:18
Snake1980 Snake1980 is offline
Baby Loader
 
Join Date: Sep 2017
Location: Italy
Posts: 8
Default

Ok...thanks!
Reply With Quote
  #8  
Old 27.08.2019, 15:45
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,554
Default

Nothing to thank me for!
__________________
JD-Dev & Server-Admin
Reply With Quote
  #9  
Old 25.05.2020, 06:35
palswim's Avatar
palswim palswim is offline
Vacuum Cleaner
 
Join Date: Dec 2014
Posts: 16
Default

Quote:
Originally Posted by Jiaz View Post
JDownloader will auto create pid file JDownloader.pid in JDownloader folder.
I had thought I wasn't seeing the PID file, but it appeared after some time.

I do not see this PID file with my JDownloader2 installation. In the JDownloader folder, I see JD2.lock and JD2.port, but no .pid file.

Last edited by palswim; 25.05.2020 at 06:40. Reason: False alarm
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 06:44.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.10 Beta 1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.