Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, anyone using HTTP::Proxy? What do you usually use for daemonizing it (and the start/stop/restart script)? I myself am planning to just utilize djb's daemontools (supervise), anyone in the same camp?

Replies are listed 'Best First'.
Re: HTTP::Proxy as a service?
by perlofwisdom (Pilgrim) on Sep 28, 2007 at 13:44 UTC
    I can't help you with HTTP::Proxy, but when I run perl as a service under windows, I simply use a sub-routine named DaemonLoop like this over-simplified example...
    ################################################################# # Function: DaemonLoop # # Description: Run our various tasks # ################################################################# sub DaemonLoop { while(1) { # <Your code here...> sleep $ENV{SLEEP_TIME}; } return 0; }
    The start/stop/restart can be handled manually with the Services Administrative Tool, or you can write a simple .cmd script and issue start/stop commands...
    echo Stopping ArchMaint >> %LOG_FILE% NET STOP ArchMaint >> %LOG_FILE% 2>&1 set SAVE_ERRORLEVEL=%ERRORLEVEL% echo Return code = %SAVE_ERRORLEVEL% >> %LOG_FILE% if not "%SAVE_ERRORLEVEL%"=="0" call :SEND_EMAIL ArchMaint not run +ning if exist %NTRESKIT%\sleep.exe %NTRESKIT%\sleep 10 echo Starting ArchMaint >> %LOG_FILE% net START ArchMaint >> %LOG_FILE% 2>&1 set SAVE_ERRORLEVEL=%ERRORLEVEL% echo Return code = %SAVE_ERRORLEVEL% >> %LOG_FILE% if not "%SAVE_ERRORLEVEL%"=="0" call :SEND_EMAIL ArchMaint start f +ailed echo Finished restarting ArchMaint >> %LOG_FILE%