I have a small Python flask webserver on an Ubuntu box (ngnix and uwsgi) that I just started using to receive and process webhooks. Part of the webhook processing can include sending an email, which I noticed causes a delay and subsequently blocks the response back to the server sending the webhook.
In researching a way to mitigate this, I discovered python-rq (aka rq), which lets me queue up a function call and then immediately respond to the webhook. In testing, this works great!
I'm testing it on my server, and to start rq I have to run rqworker
in the same directory as my website. This is great for testing, but I don't want to have to log into the server to start rq just to keep in running.
Some ideas I've come across:
- The python-rq docs mention supervisor, http://python-rq.org/patterns/supervisor/, but I don't know if I need that much overhead.
- Would a simple cron job do the trick, using reboot?
This is a small internal-only server. I don't want to over-engineer it (I feel like I'm creeping in that direction already), but I also don't want to have to babysit it to make sure all of the pieces are working.
How can I set up rqworker to run in the web site application directory on its own?