|
From: <da...@ix...> - 2003-10-01 20:32:11
|
In article <kd9...@th...>,
Mike Castle <wra...@li...> wrote:
>In article <5gc...@th...>,
>Mike Castle <wra...@li...> wrote:
>>What about if, for a while, on the NT side, if the first param is not one
>>of {start|stop|console|dump} that a warning is issued, and the param is
>>used as a config file. Then some later release, the {start|stop|console}
>>becomes mandatory?
>
>Hmmmm.... Does anyone use wrapper in a non-NT, but Win32 environment?
>
>In looking at the App.bat.in, I see all code paths goes to this line:
>
>:conf
>set _WRAPPER_CONF="%~f1"
>
>But I thought the ~f stuff was NT only. Am I mistaken?
So, I finished writing up a possible new App.cmd.in file.
@echo off
setlocal
rem
rem Find the application home.
rem
rem %~dp0 is name of current script under NT
set _APP_HOME=%~dp0
rem : operator works similar to make : operator
set _APP_HOME=%_APP_HOME:\bin\=%
set _WRAPPER_EXE=%_APP_HOME%\bin\Wrapper.exe
rem Find the requested command.
for /F %%v in ('echo %1^|findstr "^console$ ^start$ ^stop$ ^restart$
^install$ ^remove"') do call :exec set COMMAND=%%v
if "%COMMAND%" == "" (
echo WARNING: Defaulting to running in console mode is deprecated. 1>&2
set COMMAND=console
) else (
shift
)
rem
rem Find the wrapper.conf
rem
:conf
set _WRAPPER_CONF="%~f1"
if not %_WRAPPER_CONF%=="" goto startup
set _WRAPPER_CONF="%_APP_HOME%\conf\wrapper.conf"
rem
rem Run the application.
rem At runtime, the current directory will be that of Wrapper.exe
rem
if not exist "%_APP_HOME%\logs" mkdir "%_APP_HOME%\logs"
call :%COMMAND%
if errorlevel 1 pause
goto :eof
:console
echo on
"%_WRAPPER_EXE%" -c %_WRAPPER_CONF%
goto :eof
:start
"%_WRAPPER_EXE%" -t %_WRAPPER_CONF%
goto :eof
:stop
"%_WRAPPER_EXE%" -p %_WRAPPER_CONF%
goto :eof
:install
"%_WRAPPER_EXE%" -i %_WRAPPER_CONF%
goto :eof
:remove
"%_WRAPPER_EXE%" -r %_WRAPPER_CONF%
goto :eof
:restart
call :stop
call :start
goto :eof
:exec
%*
goto :eof
Since the old App.bat.in used NT specific features in the main line anyway,
and since no one complained about it not working on 9x, I made the
assumption that no one is actually using Wrapper in a non-NT environment.
Therefore, I decided to it completely NT specific.
Unfortunately I don't have an NT4.0 handy, so I hope it still works on
that. I don't think I used any 2K specific features.
I renamed the file from .bat to .cmd to reflect the NT specific nature of
the file.
I used setlocal to avoid having to undef envvars at the end of the script.
It now supports console|start|stop|restart|install|remove, so it's now very
similar to the Unix script. Note that the Unix script still supports the
dump command, and the NT script supports install and remove. Regarding
dump via NT service, I think the another thread addresses that issue and
may give room for thought.
With this script, the extra install/uninstall scripts are no longer
necessary.
I'm still undecided about remove versus uninstall for the command.
Actually no reason it can't be both.
The Unix script can stop one started via console; the NT script cannot.
The Unix script currently does not handle taking a second parameter to use
as a config file. I think that if the NT one does, then the Unix one
should be similarly enhanced.
Still not sure about the whole deprecated message. No feed back from the
list on that design point. I think both platforms should function
similarly, and if the Unix script requires a command, then the NT one
should.
Enjoy!
mrc
--
Mike Castle da...@ix... www.netcom.com/~dalgoda/
We are all of us living in the shadow of Manhattan. -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); -- gcc
|