How to serve CherryPy application in mulitple ports independently?

210 Views Asked by At

I am using CherryPy to serve my application in multiple ports say 8080 and 8081

cherrypy.server.unsubscribe()

for port in [8080, 8081]:
    server = Server()
    server.socket_port = port
    server.socket_host = "0.0.0.0"
    server.thread_pool = 100
    server.subscribe()
cherrypy.engine.start()
cherrypy.engine.block()

With this the application is being served as expected on both the ports. Now due to some reason I want to stop the server of a specific port and other being served normally. When I stop the process on a particular port with the following command,

fuser -k "$port"/tcp

All the process on the ports in which the application was started (8080, 8081) are also being killed. Is this an expected behaviour ?

If yes, is there anyway I can achieve serving the application independently without affecting the other ports on which it is running ? (Other than like I should change the port in the source code and run it again manually)

If no, what is the mistake I am doing here ?

Any help would be appreciated!

0

There are 0 best solutions below