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

How to get autoreload work #8

Open
kellytrinh opened this issue Jul 15, 2020 · 3 comments
Open

How to get autoreload work #8

kellytrinh opened this issue Jul 15, 2020 · 3 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@kellytrinh
Copy link

Hi Todd,

Found your package when google searching for a simple webhook server. Its great - simple for a beginner at python like me.

Could I get some help tho - I see there is a 'autoreload' and it suggests that I can edit the source code and have the changes reflect on the server immediately (that's great for developing/debugging).

However, it does not seem to be working. When I set logScreen and autoReload to true; I get the output below. It seems to suggest that the file change notification is received but after the webserver is shutdown; it doesn't come back up again.

Am I missing a step?

[15/Jul/2020:12:37:18] ENGINE Bus STARTING
Still alive...
[15/Jul/2020:12:37:18] ENGINE Started monitor thread 'Autoreloader'.
[15/Jul/2020:12:37:18] ENGINE Serving on http://0.0.0.0:8090
[15/Jul/2020:12:37:18] ENGINE Bus STARTED
Received request:
[[[details of request elided ]]]
192.168.0.100 - - [15/Jul/2020:12:37:19] "POST /webhook-serrer HTTP/1.1" 200 2 "" "curl/7.58.0"
[15/Jul/2020:12:37:26] ENGINE Restarting because /home/kelly/system/testing/webserver.py changed.
[15/Jul/2020:12:37:26] ENGINE Stopped thread 'Autoreloader'.
[15/Jul/2020:12:37:26] ENGINE Bus STOPPING
[15/Jul/2020:12:37:26] ENGINE HTTP Server cherrypy._cpwsgi_server.CPWSGIServer(('0.0.0.0', 8090)) shut down
[15/Jul/2020:12:37:26] ENGINE Bus STOPPED
[15/Jul/2020:12:37:26] ENGINE Bus EXITING
[15/Jul/2020:12:37:26] ENGINE Bus EXITED
Still alive...
@toddrob99
Copy link
Owner

Believe it or not, I have actually never tried to use the autoReload option. I will try to dig into this. Sorry it's taken so long even to respond.

@toddrob99 toddrob99 self-assigned this Jul 26, 2020
@toddrob99 toddrob99 added the bug Something isn't working label Jul 26, 2020
@kellytrinh
Copy link
Author

No problem; take your time; it is kind enough you share with everyone to make use of...

@toddrob99
Copy link
Owner

I tried to reproduce the issue, and I don't even get the log entry from cherrypy that it's restarting the engine. I am testing with example.py that's included in this repository. I added autoReload=True to line 80:

webhooks = webhook_listener.Listener(port=port, handlers={"POST": parse_request}, autoReload=True)

Then ran the script with the -v argument and sent a POST request. I saw the request in the log.

I then made a change to example.py (added a log entry at line 74: logger.debug("test")). There was no log entry written about the cherrypy engine restarting or exiting. I sent another POST request, which failed with a "connection refused" error, presumably because, although I didn't get the log entries, the cherrypy engine exited like you are seeing.

The only code related to cherrypy auto-reload is to first accept the keyword argument when creating the Listener instance on line 23:

self.autoReload = kwargs.get("autoReload", False)

and then to pass that value in to the cherrypy engine on line 43:

"engine.autoreload.on": self.autoReload,

I don't think there's much I can do to fix this behavior (I am not an expert with the cherrypy engine), but if anyone else would like to give it a shot, feel free to submit a pull request. Also note that autoReload should only be used during testing, so I do not consider this to be a critical feature.

@toddrob99 toddrob99 added the help wanted Extra attention is needed label Jul 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants