I got a half-solution. Inspecting the wrapper script code, as suggested by @Naytzyrhc, I found that the wrapper lib reads 3 files to create the status message:
bin/my-app.pid
to print the PID of the running process;bin/my-app.status
to print the status of the wrapper itself;bin/my-app.java.status
to print the status of the wrapped application.
So, in the application code, to override the status message, just write the message in the my-app.java.status
file.
There's only one gotcha: if the status message contains line breaks, the service my-app status
doesn't print them, because it uses the echo
command (as stated in this question Capturing multiple line output into a Bash variable). To solve this problem, just change the line from:
eval echo `gettext '$APP_LONG_NAME is running: PID:$pid, Wrapper:$STATUS, Java:$JAVASTATUS'`
to:
eval echo `gettext '$APP_LONG_NAME is running: PID:$pid, Wrapper:$STATUS, Java:"$JAVASTATUS"'`
(Using double quotes on $JAVASTATUS
).
This is a half-solution because it doesn't fire an event to the running application, as I wanted. But it works for customizing the status message: it depends on the application how often the message is updated.