On Wed, 2010-10-06 at 12:29 +0200, Friedrich Clausen wrote: > Hi All, > > I am trying to run some Java programs under daemontools and it is > working quite well. Except they are running as root and I would like > to make them run as www-data. I found the daemontools "setuidgid" > program which works for well for starting up the application but then > daemontools cannot shut the application down again. Here is an example > of the daemontools run job - > > #!/bin/bash > # /etc/service/myapplication/run startup script > source /etc/default/myapplication > exec setuidgid www-data java -jar /opt/webapps/myapplication.jar > --port 9000 --headless >> /opt/logs/myapplication.log 2>&1 >
You may want to look into jsvc - this has some similar capabilities. For example, have a look at the init script for tomcat - this should be a good template > when I leave out the setuidgid stuff then I am able to start and stop > the application. But with the above example the shutdown signal does > not seem to reach the Java process even though I am using exec. Java processes tend to be a bit nasty here: e.g. tomcat is intended to shut down when told (nicely) to shut down - by receipt of a message. But if it is wedged, then it will not reply and needs to be killed. Again, the init script for tomcat should be instructive here. Hope this helps -- Karl E. Jørgensen Geek