how to shut down cherrypy server?
Asked Answered
S

2

9

im on win7 ,i started a tutorial helloworld.py and everything doing fine but i don't know how to quit the service.i use

quit()

but command line give me an error message and exit.but service is still running and take my 8080 port. i hadn't find a way to shut down it manually.

  File "C:\python32\lib\site-packages\cherrypy\process\wspbus.py", line 197, in
publish
    output.append(listener(*args, **kwargs))
  File "C:\python32\lib\site-packages\cherrypy\_cpserver.py", line 151, in start

    ServerAdapter.start(self)
  File "C:\python32\lib\site-packages\cherrypy\process\servers.py", line 167, in
 start
    wait_for_free_port(*self.bind_addr)
  File "C:\python32\lib\site-packages\cherrypy\process\servers.py", line 410, in
 wait_for_free_port
    raise IOError("Port %r not free on %r" % (port, host))
IOError: Port 8080 not free on '0.0.0.0'
Showy answered 28/8, 2012 at 9:1 Comment(0)
C
7

According to this page, quit() is not appropriate for this task.

Depending on how you run your server, you should consider using cherrypy.engine.exit:

>>> help(cherrypy.engine.exit)
exit(self) method of cherrypy.process.win32.Win32Bus instance
    Stop all services and prepare to exit the process.
Cacus answered 28/8, 2012 at 9:7 Comment(0)
R
8

Include this in your python file.

@cherrypy.expose

def shutdown(self):  
    cherrypy.engine.exit()

Then add a link on your page.

<a id="shutdown"; href="./shutdown">Shutdown Server</a>
Roesch answered 23/4, 2013 at 0:49 Comment(0)
C
7

According to this page, quit() is not appropriate for this task.

Depending on how you run your server, you should consider using cherrypy.engine.exit:

>>> help(cherrypy.engine.exit)
exit(self) method of cherrypy.process.win32.Win32Bus instance
    Stop all services and prepare to exit the process.
Cacus answered 28/8, 2012 at 9:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.