You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Mladen Turk <mt...@apache.org> on 2005/02/21 13:31:12 UTC

Changing the Tomcat5 WIN32 service runner

Hi,

For anyone interested there is a new project for
jakarata-commons/daemon procrun named *srvbatch*,
siting there for couple of months.

Unlike any other java or java/jni implementations
it does not tries to make a java as a service, but
rather makes a batch (.bat) file as a service.

This way the same configuration (catalina.bat)
can be used both for running from command line or
for running from service.

It usually needs a separate batch file that is closely
related to any unix service file (see exservice.bat).

What do you think that we change the current
windows distribution to follow this new concept?

IMO it's more simpler and stable then current
way the procrun is used.


Regards,
Mladen

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: Changing the Tomcat5 WIN32 service runner

Posted by Costin Manolache <cm...@yahoo.com>.
Mladen Turk wrote:
> 
> @if "%1" == "install"   goto cmdInstall
> @if "%1" == "uninstall" goto cmdUninstall
> @if "%1" == "start"     goto cmdStart
> @if "%1" == "stop"      goto cmdStop
> @if "%1" == "restart"   goto cmdRestart
> echo Usage
> goto cmdEnd


I assume the '.bat' is the only option - i.e. could you use arbitrary 
'executables' or other 'scripting languages' ? I.e. if you have cygwin 
or equivalent installed - could it execute a .sh ? Or if you have 
different scripting engine - could it run the .js or .py instead of 
.bat? And the most interesting - could you specify an executable .jar as 
the command ?

It's just that .bat is one of the ugliest scripting languages...

Having the unix-style service mechanism, i.e. a script with 
start/stop/etc is IMO a step forward and makes it much easier to
deal with services.

Costin


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: Changing the Tomcat5 WIN32 service runner

Posted by Mladen Turk <mt...@apache.org>.
Costin Manolache wrote:
> William A. Rowe, Jr. wrote:
> 
> Would it be possible to have the signals intercepted and cause the
> execution of the .bat file with different params ( like 'stop' or 
> 'reload' or 'start' ), similar with unix init.d files ?
>

Yes, that was the idea.
Here is the example from the svn.

@echo off
@if not "%ECHO%" == ""  echo %ECHO%
@if "%OS%" == "Windows_NT"  setlocal

set SERVICE_EXECUTABLE=example.exe

REM Figure out the running mode

@if "%1" == "install"   goto cmdInstall
@if "%1" == "uninstall" goto cmdUninstall
@if "%1" == "start"     goto cmdStart
@if "%1" == "stop"      goto cmdStop
@if "%1" == "restart"   goto cmdRestart
echo Usage
goto cmdEnd

:cmdInstall
..\Debug\srvbatch.exe -iwdcl SrvbatchExample "%CD%" "Srvbatch Example 
Service" "This is an Example service" exservice.bat
goto cmdEnd

:cmdUninstall
..\Debug\srvbatch.exe -u SrvbatchExample
goto cmdEnd

:cmdStart
%SERVICE_EXECUTABLE% start
goto cmdEnd

:cmdStop
%SERVICE_EXECUTABLE% stop
goto cmdEnd

:cmdRestart
%SERVICE_EXECUTABLE% stop
%SERVICE_EXECUTABLE% start
goto cmdEnd

:cmdEnd

So just set SERVICE_EXECUTABLE to catalina.bat

> I like the idea of running a .bat ( or arbitrary .exe ) as a service 
> based on the analogy with the init.d files - but it needs the 
> stop/restart as well.
> 

Well, it's much easier to maintain setups when you have multiple
servers. You don't need to edit the registry for runtime params.

OTOH it has overhead of spawning aditional cmd.exe, so this perhaps
will be better used as additional package rather then default service
runner.


Mladen.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: Changing the Tomcat5 WIN32 service runner

Posted by Costin Manolache <cm...@yahoo.com>.
William A. Rowe, Jr. wrote:
> At 06:31 AM 2/21/2005, Mladen Turk wrote:
> 
> 
>>Unlike any other java or java/jni implementations
>>it does not tries to make a java as a service, but
>>rather makes a batch (.bat) file as a service.
> 
> 
> IIUC, that means;
> 
>   1. service signals (shutdown etc) aren't recognized by cmd 
>      (sh for you linux observers) in any useful manner.
> 
>   2. it invokes cmd, which invokes the apps.  You are stuck
>      with an instance of cmd for the lifetime of the process.
> 
> Seems like a big leap backwards, IMHO.  If anything, a psuedo-sh
> script interpreter which picked up the envvar assignments (the
> only thing you want to move to .cmd for, anyways) makes more
> sense than this.

Would it be possible to have the signals intercepted and cause the
execution of the .bat file with different params ( like 'stop' or 
'reload' or 'start' ), similar with unix init.d files ?

I like the idea of running a .bat ( or arbitrary .exe ) as a service 
based on the analogy with the init.d files - but it needs the 
stop/restart as well.

Costin


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: Changing the Tomcat5 WIN32 service runner

Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
At 06:31 AM 2/21/2005, Mladen Turk wrote:

>Unlike any other java or java/jni implementations
>it does not tries to make a java as a service, but
>rather makes a batch (.bat) file as a service.

IIUC, that means;

  1. service signals (shutdown etc) aren't recognized by cmd 
     (sh for you linux observers) in any useful manner.

  2. it invokes cmd, which invokes the apps.  You are stuck
     with an instance of cmd for the lifetime of the process.

Seems like a big leap backwards, IMHO.  If anything, a psuedo-sh
script interpreter which picked up the envvar assignments (the
only thing you want to move to .cmd for, anyways) makes more
sense than this.




---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: Changing the Tomcat5 WIN32 service runner

Posted by Remy Maucherat <re...@apache.org>.
Mladen Turk wrote:
> Hi,
> 
> For anyone interested there is a new project for
> jakarata-commons/daemon procrun named *srvbatch*,
> siting there for couple of months.
> 
> Unlike any other java or java/jni implementations
> it does not tries to make a java as a service, but
> rather makes a batch (.bat) file as a service.
> 
> This way the same configuration (catalina.bat)
> can be used both for running from command line or
> for running from service.
> 
> It usually needs a separate batch file that is closely
> related to any unix service file (see exservice.bat).
> 
> What do you think that we change the current
> windows distribution to follow this new concept?
> 
> IMO it's more simpler and stable then current
> way the procrun is used.

I'm not in favor of that :( I hate .bat files, so ...

Rémy

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org