On 12/01/16 10:54, Muayyad AlSadi wrote:
the problem here is the bash script wrapped around

in the good old days of solr there used a param passed to solr.jar to
make the fork magic in java (maybe it was --daemon)
but now it's done in bash with "nohup" followed by "while true .... lsof
-PniTCP:$SOLR_PORT -sTCP:LISTEN" to detect if it's up before exit

This script, right?

 nohup "$JAVA" "-Dzookeeper.log.dir=${ZOO_LOG_DIR}" 
"-Dzookeeper.root.logger=${ZOO_LOG4J_PROP}" \
-cp "$CLASSPATH" $JVMFLAGS $ZOOMAIN "$ZOOCFG" > "$_ZOO_DAEMON_OUT" 2>&1 < /dev/null 
&
if [ $? -eq 0 ]

Now, this script

 - Runs the process using nohup
 - Merges stderr with stdout
 - Forks directly on start.
 - Uses a bash parent as pid.

Nothing of this makes systemd's task simpler. Personally, I'd consider three routes:

- If the socket availability doesn't matter, remove the nohup, redirection, fork stuff and use a "Type = simple" service. Presuming that the java process runs in foreground this should be fine.

- If the java process runs in background anyway, it could be fixed by teaching it to write a pidfile (-> Type = forking). This should be a simple fix which could be upstreamed.

- If you need to socket(s) to be available and type = forking doesn't make it (exits parent to early, doesn't fork) the code should be fixed by teaching it to issue a sd_notify (-> Type = notify).

Just my 5 öre.


Cheers!

--alec


--
devel mailing list
devel@lists.fedoraproject.org
http://lists.fedoraproject.org/admin/lists/devel@lists.fedoraproject.org

Reply via email to