openhab / openhab-syno-spk

openHAB Synology SPK Install Package
Eclipse Public License 2.0
161 stars 42 forks source link

1.8.1 Package unstoppable #13

Closed fsedarkalex closed 7 years ago

fsedarkalex commented 8 years ago

Hi!

for some reason the stop button is not working correctly. I debugged it a bit and noticed that openHAB does not react to the normal kill signal.

I did a workaround but it's not a good idea to do it like that I think (stop_runtime.sh):

#!/bin/sh
PID=$(cat ~/.daemon.pid)
rm -f ~/.daemon.pid
kill $PID
sleep 12
kill -9 $PID

I let OH 12 seconds before killing but I think that does not change anything... Probably one should send stop commands directly to the osgi framework?

cniweb commented 8 years ago

Hi @fsedarkalex,

under what firmware your package runs? We have 2 branches, for <= 5.2 and 6.0...

What a DS model you use?

Thank you for your involvement!

Chris

fsedarkalex commented 8 years ago

Well I don't use a real DS :) I am a user of XPenology (Synology DSM on x86 hardware) but there is no difference in the OS. The only difference is the Bootloader. Guess the x86 is what you wanted to know though...

I'm currently running on latest stable 5.2 update

cniweb commented 8 years ago

@kaikreuzer Can you help me? -> Probably one should send stop commands directly to the osgi framework?

fsedarkalex commented 8 years ago

Well I can help :) You have to send "stop 0" to console for openhab 1.x or "logout" for 2.x followed by a linebreak

cniweb commented 8 years ago

OK, How the command should look like in the stop_runtime.sh script?

fsedarkalex commented 8 years ago

I am trying... please be patient I'm near a solution

fsedarkalex commented 8 years ago
#!/bin/ash
PID=$(cat ~/.daemon.pid)
counter=0

{ sleep 3; printf "stop 0\n"; sleep 3; } | telnet 127.0.0.1 5555

while true;
do
    if [ -e /proc/${PID} -a /proc/${PID}/exe ]
    then
        if [ $counter -gt 19 ];
        then
            kill -9 $PID
            break
        fi
        counter=$((counter+1))
        echo "openhab is still running with pid $PID. Waiting for 3 more seconds"
        sleep 3
    else
        echo "openhab has terminated as expected."
        break
    fi
done

rm -f ~/.daemon.pid

that's the solution under a normal envronment but unfortunately busybox does not allow piping to telnet... Sorry BusyBox is not my special friend :d Probably someone else has an idea how to pass the stop command to the osgi telnet console?

//Edit: Probably @kaikreuzer has a better Idea...

kaikreuzer commented 8 years ago

Better ask @teichsta for help on OH 1.8... With OH 2, the kill (even the soft one using "kill -2" which equals a Ctrl+C) works well and in any case you should probably rather use ./runtime/karaf/bin/start and ./runtime/karaf/bin/stop for OH2.

cniweb commented 8 years ago

@fsedarkalex can you try "kill -2"? It is better?

cniweb commented 7 years ago

The installation work now? Can we close this issue?