Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_cpserver.stop() can't use #42

Closed
ghost opened this issue Nov 25, 2004 · 3 comments
Closed

_cpserver.stop() can't use #42

ghost opened this issue Nov 25, 2004 · 3 comments

Comments

@ghost
Copy link

ghost commented Nov 25, 2004

Originally reported by: Anonymous


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


@ghost
Copy link
Author

ghost commented Nov 26, 2004

Original comment by 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):

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
)

If our name is still ends with '(First Run)' then change our setup

displayName = win32service.QueryServiceConfig(service)[8]
if displayName.endswith(self.endfirst):

Make our service autostart and change it's name so this isn't run

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.

@ghost
Copy link
Author

ghost commented Dec 7, 2004

Original comment by Anonymous:


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

@ghost
Copy link
Author

ghost commented Dec 14, 2004

Original comment by Anonymous:


Fixed

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

0 participants