Page 2 of 2

Re: PostProcessing doesnt work?

Posted: February 14th, 2008, 5:17 pm
by switch
Yes that is right, the 'core' of the program resides in library.zip. The exe's are just front-ends to that file(sort of)

Re: PostProcessing doesnt work?

Posted: February 14th, 2008, 5:49 pm
by shypike
Someone else in the forum has an alternative way to start as service:

http://forums.sabnzbd.org/index.php?topic=284.0

If you cannot keep it running with anysrv, maybe this will work.

Re: PostProcessing doesnt work?

Posted: February 14th, 2008, 6:05 pm
by Usenet
Thanks for the help. I'll try anything to get it to run as a service ;).
ANy idea what the signal 5 means?

Re: PostProcessing doesnt work?

Posted: February 15th, 2008, 5:30 am
by Usenet
I found it: http://msdn2.microsoft.com/en-us/librar ... S.85).aspx

dwCtrlType

    The type of control signal received by the handler. This parameter can be one of the following values.
    Value Meaning

    CTRL_C_EVENT
    0
    A CTRL+C signal was received, either from keyboard input or from a signal generated by the GenerateConsoleCtrlEvent function.

    CTRL_BREAK_EVENT
    1
    A CTRL+BREAK signal was received, either from keyboard input or from a signal generated by GenerateConsoleCtrlEvent.

    CTRL_CLOSE_EVENT
    2
    A signal that the system sends to all processes attached to a console when the user closes the console (either by clicking Close on the console      window's window menu, or by clicking the End Task button command from Task Manager).

    CTRL_LOGOFF_EVENT
    5
    A signal that the system sends to all console processes when a user is logging off. This signal does not indicate which user is logging off, so no assumptions can be made.

    Note that this signal is received only by services. Interactive applications are terminated at logoff, so they are not present when the system sends this signal.


    CTRL_SHUTDOWN_EVENT
    6
  A signal that the system sends when the system is shutting down. Interactive applications are not present by the time the system sends this signal, therefore it can be received only be services in this situation. Services also have their own notification mechanism for shutdown events. For more information, see Handler.

    This signal can also be generated by an application using GenerateConsoleCtrlEvent.

Re: PostProcessing doesnt work?

Posted: February 15th, 2008, 7:29 am
by Usenet
looking at the code

Code: Select all

################################################################################
# Signal Handler                                                               #
################################################################################
def sig_handler(signum = None, frame = None):
    if type(signum) != type(None):
        logging.warning('[%s] Signal %s caught, saving and exiting...', __NAME__, signum)
    try:
        save_state()
    finally:
        os._exit(0)

Code: Select all

win32api.SetConsoleCtrlHandler(sabnzbd.sig_handler, True)
With ref http://aspn.activestate.com/ASPN/docs/A ... _meth.html it looks to me as if any signal caught will cause SABnzbd to quit?
An exception to "CTRL_LOGOFF_EVENT" 5 in case the -d switch is used should maybe be added?

(Im a complete py n00b so correct me if Im wrong ;) )

Re: PostProcessing doesnt work?

Posted: February 15th, 2008, 10:13 am
by shypike
Thanks for the info. I simply never gave it a thought before.
Until we introduced a "windowed" version of SABnzbd, I never had a problem with run-as-service.
I still don't with SABnzbd-console.exe.

I'll pick up your suggestion about signal handling anyway, thanks.

Re: PostProcessing doesnt work?

Posted: February 15th, 2008, 10:15 am
by Usenet
Glad I can help :)
Just trying to figure out how to "compile" the source for win.. something with py2win.exe ... ;)

Re: PostProcessing doesnt work?

Posted: February 16th, 2008, 4:53 pm
by Usenet
GREAT, now the service works!! Thanks for great work! :)

I have an addition to the "service" instructions on the wiki (and a few corrections but i skip em now..):

Create an 'AppParameters' value of type REG_SZ and specify the parameters for your app. For Example: AppParameters: REG_SZ: -d -f C:\bin\sabnzbd.ini

Doing this you can skip running startup scrips etc..

Re: PostProcessing doesnt work?

Posted: February 17th, 2008, 5:55 pm
by Usenet
Great you updated the wiki.
PLease also change

Code: Select all

instsrv "c:\Program Files\Windows Resource Kits\Tools\srvany.exe"
to

Code: Select all

instsrv SABnzbd "c:\Program Files\Windows Resource Kits\Tools\srvany.exe"
to make it easier for first-timers ;)

Re: PostProcessing doesnt work?

Posted: February 18th, 2008, 4:30 am
by shypike
Thanks, page has been updated.

Re: PostProcessing doesnt work?

Posted: February 18th, 2008, 2:44 pm
by Usenet
did a remake for my friends:

First download the Windows 2003 Resource kit from the Microsoft site and install it. Next, assuming that SABnzbd is installed in c:\bin\sabnzbd, do the following steps.

run in a cmd window:

Code: Select all

instsrv SABnzbd "c:\Program Files\Windows Resource Kits\Tools\srvany.exe"
run in a cmd window:

Code: Select all

install_service.reg
Content of install_service.reg, create a text file containing: (modify the path to match your setup.)

Code: Select all

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SABnzbd\Parameters]
"AppDirectory"="d:\\bin\\SABnzbd"
"Application"="D:\\bin\\SABnzbd\\SABnzbd.exe"
"AppParameters"="-d -f d:\\MyWorkDir\\sabnzbd.ini"
Set dependency, by running in a cmd.exe window:

Code: Select all

sc config SABnzbd depend= Tcpip
Now go to start -> run -> compmgmt.msc . Set a suitable user account for the service "SABnzbd" by creating a user account under "local users and groups". Under "Services and Programs" Choose "Services" and right click for properties for the "SABnzbd" service and specify the user account to run the service. Make sure the service has the "automatic" start up option

Start the service