Issue #42 resolved

_cpserver.stop() can't use

Anonymous created an issue

I user cpg.server.stop() to call _cpserver.stop() so stop website

and I found in _cphttpserver.py shutdown() is not defined!

Reported by lihuimail@gmail.com

Comments (7)

  1. Anonymous

    this from maillist:

    How to stop cp2 server with nt services

    Hi

    I make cp2 with nt service, and it work fine,but it can't stop or restart

    this is my code for install nt service:

    I copy from forum list of cp1.cherry.py and changed:

    import os import sys import win32service import win32serviceutil import win32event import win32evtlogutil import servicemanager

    class MyAppService(win32serviceutil.ServiceFramework):

    _endfirst_='(First Run)'

    _svc_name_ = "MyApp"

    _svc_display_name_ = "%s %s"%(_svc_name_,_endfirst_) _svc_deps_ = ["EventLog"] def setup(self):

    1. Get a handle on our service scm = win32service.OpenSCManager( None,None, win32service.SERVICE_QUERY_CONFIG| win32service.SERVICE_CHANGE_CONFIG ) service = win32service.OpenService( scm,self._svc_name_, win32service.SERVICE_QUERY_CONFIG| win32service.SERVICE_CHANGE_CONFIG )
    1. If our name is still ends with '(First Run)' then change our setup displayName = win32service.QueryServiceConfig(service)[8] if displayName.endswith(self._endfirst_):
    2. Make our service autostart and change it's name so this isn't run
    3. again win32service.ChangeServiceConfig( service, win32service.SERVICE_NO_CHANGE, win32service.SERVICE_AUTO_START, win32service.SERVICE_NO_CHANGE, None,None,False,None,None,None, self._svc_name_ )

    def SvcStop(self): import sys sys.exit(0)

    or is cpg.server.stop(),but cpg.server.stop() can't work

    def SvcDoRun(self): self.setup() import instService instService.start() #--in this module call cpg.server.start(.....) ...

    if name == 'main': win32serviceutil.HandleCommandLine(MyAppService)

    Reply

    Details: Show quoted text | View source | Unwrap Lines | Forward

    Remi Delon Nov 25, 7:51 am show options

    From: Remi Delon <r...@cherrypy.org> Date: Thu, 25 Nov 2004 15:51:29 +0000 Local: Thurs, Nov 25 2004 7:51 am Subject: Re: How to stop cp2 server with nt services Reply | Reply to Author | Forward | Print | Show original

    def SvcStop(self): import sys sys.exit(0)

    or is cpg.server.stop(),but cpg.server.stop()

    can't work

    You're right, it should be cpg.server.stop(), but it has a bug right now and it doesn't work (I'm having the same problem).

    Can you add a ticket in Trac for that ?

    Thanks,

    Remi.

  2. Anonymous

    Is it an option to use the 'atexit' module for registering clearnup actions, then call the exit handler and call os._exit(0) ?

  3. Log in to comment