openhab / openhab-linuxpkg

Repo for Linux packages
Eclipse Public License 2.0
18 stars 33 forks source link

bug correction in /etc/init.d/openhab2 ensuring the PID si correctly set in the pidfile #146

Closed oliviercommelarbre closed 4 years ago

oliviercommelarbre commented 5 years ago

starting openhab from within the monit daemon results in an empty pidfile. This is systematic on my raspbian config. Debugging the issue shows that the findpid function indeed involves a grep "openhab2.*java" on the output of the 'ps aux' command that will not find a match unless there are enough characters to hold the long java command line output by the ps command. Solution: i prefixed the 'ps aux' with 'COLUMNS=3000' that ensures that it will be the case.

BClark09 commented 5 years ago

Hi @oliviercommelarbre, thanks for the debugging and for the fix! :)

If it's ps_aux that has the initial issue, it will be better to try and avoid it completely. When grepping openhab2.*java does not work, does the following command produce the correct PID?:

pgrep -f openhab2.*java

If it does, would you be able to adjust the PR accordingly? Remember to sign off your commit too e.g. Signed-off-by: Joe Smith <joe.smith@email.com>


Out of interest, is there any reason why you are using init.d instead of systemd for Raspbian?

oliviercommelarbre commented 5 years ago

very elegant solution indeed, thank you, now successfully tested. It also allows to streamline the overall function coding with the sole use of pgrep.

Sorry i'm not very proficient with github. i've generated two new commits (that in fact could make the former ones obsolete since they edit the same line of code), but i'm not sure what to do to cancel the former commits (not signed off) to make the overall thing pass the check. Could you may be hint me?

regarding your question, i've built my openhab setup on top of an existing config of the RPI (that manages the geotermal plant at lower level) that happens to use init.d. Actually it rather uses monit even to launch daemons at startup (i.e. not init.d properly speaking, but the monit config points to the start/stop triggering scripts found in of /etc/init.d). hope it clarifies!

oliviercommelarbre commented 5 years ago

Dear @BClark09, btw if you agree with this change, i've no problem whatsoever in you doing the edit directly under your authorship (and btw you are the one who made that good suggestion of using pgrep), that could even save you from teaching me how to do things properly on github, i'll do it properly next time!

BClark09 commented 4 years ago

Thank you for the fix and so sorry this took so long to merge!