how to run background job in web.py?

725 views Asked by At
  1. I use web.py to process incoming data by "GET" and "POST" method and uses app.run(). This looks will run in loop and never stop.

  2. I also have a background job which detect port "9xxx" and process the incoming data, send msg to other servers to push msg to phone. I also uses a while(true) loop to do this.

How to integrate (2) into (1)? I'm confused.

I used to plan run (1) and (2) independently but there has data exchange so not convenience to code. how do you web.py users do these similar things?

1

There are 1 answers

3
McGrady On BEST ANSWER

I think this is what you want:

nohup python web.py > web.log 2>&1 &

Check out nohup wiki and man page

In production ,I'd like combine web.py with uwsgi and nginx.You can read this and have a try.And then I use supervisord to restarts server after they terminate.