Starting/stopping Java processes is always a pain, many people go with java service wrapper, which is good, but I'm not sure where it's at these days, last I heard the company was applying a dodgy sort of open source sort of not open source license to it.
I think what jetty's script does, ie use the Debian start_stop_daemon if it's available, is good. My target platform is RedHat, so I've modified the script to be able to use the RedHat functions if they are available, but I've also made a number of other changes for my companies specific use case. Next week I'll see if I have time to prepare a patch with just what's required for RedHat scripts. Using the RedHat scripts gives the nice ok/failed status messages.
By the way, the RedHat /etc/rc.d/init.d/functions daemon function passes the -s option to su too when starting a process as another user. On 28.10.2011, at 17:42, Joakim Erdfelt wrote: Good information.
Got any examples of a "best of breed" startup script for any other java server/daemon we can learn off of? -- Joakim Erdfelt
(the people behind jetty and cometd)
On Fri, Oct 28, 2011 at 8:07 AM, James Roper <JRoper@xxxxxx> wrote:
Hi,
There is conflicting information between jetty.conf and the actual behaviour. jetty.conf contains this comment:
Each line in this file becomes an arguement to start.jar
unless this file contains an --ini option, then these
arguments will be in addition to those found in the
start.ini file
I would interpret that to mean, if no --ini option is loaded, the jetty's start.ini is not loaded. However, in the code, we see this:
boolean ini = false;
....
if (arg.startsWith("--ini=")||arg.equals("--ini"))
{
ini=true;
....
then later
// if no non-option inis, add the start.ini
if (!ini)
{
arguments.addAll(0,loadStartIni(null));
}
so, the code says, if --ini=somefile.ini is present, load that, if --ini *is* present, load nothing, and if no --ini is present, load start.ini. Seems to be a bug here?
Also, the command to start jetty in jetty.sh on non debian distros (ie, with no start_stop_daemon function present) as a different user will in most cases fail, because it uses
su - <user> -c "....
It is very common for a system administrator to set the shell of the user that the webserver runs as to /bin/false so that they can't log in, and su by default will execute the users shell followed by the commands passed in, so the above command will do nothing. What it probably should be is su - <user> -s /bin/sh -c "..., which forces su to use a real shell.
James
VZ Netzwerke Ltd || Saarbruecker Str. 38 || D - 10405 Berlin
JRoper@xxxxxx
www.studivz.net, www.meinvz.net, www.schuelervz.net
VZ Netzwerke Ltd, Registered Office Berlin, Registration Court Charlottenburg, HRB 101454
Executive Director: Stefanie Waehlert
Non-Executive Directors: Claas van Delden, Markus Schunk, Thomas Baum, Dr. Clemens Riedl
Headquarters: VZ Netzwerke Ltd, 5 New Street Square, London EC4A 3TW, United Kingdom
Companies House Cardiff No. 5607971, Place of Registration: England and Wales
_______________________________________________
jetty-dev mailing list
jetty-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-dev
<ATT00001..txt>
VZ Netzwerke Ltd || Saarbruecker Str. 38 || D - 10405 Berlin
JRoper@xxxxxx
www.studivz.net, www.meinvz.net, www.schuelervz.net
VZ Netzwerke Ltd, Registered Office Berlin, Registration Court Charlottenburg, HRB 101454
Executive Director: Stefanie Waehlert
Non-Executive Directors: Claas van Delden, Markus Schunk, Thomas Baum, Dr. Clemens Riedl
Headquarters: VZ Netzwerke Ltd, 5 New Street Square, London EC4A 3TW, United Kingdom
Companies House Cardiff No. 5607971, Place of Registration: England and Wales
|