Domanda

I am sort of new to hosting web applications, but have a running Python application using webpy deployed on an apache server with mod_wsgi. It seems to run just fine, except that while I am using the app, apache seemingly randomly reloads the webpy app (app.py) from scratch often.

It loads quickly so it's seamless, but it resets all the users data that's internal to the app. Is this supposed to be happening? Do I need to be writing all the data to files continuously? If not, how can I keep the app running until I want to stop it?

Thanks!

È stato utile?

Soluzione

First off, if possible it may be best to store your data client side as much as possible, it can make life much easier. Storing in a database or writing to disk are also valid options, but keep in mind that databases are designed to be accessed simultaneously, whereas individual files are not, so you would need to design your storage mechanism carefully.

Some servers are configured to kill idle processes automatically in order to save on resources. I can't say for sure that's the case, but you might check the following settings for WSGIDaemonProcess in your httpd config:

maximum-requests=nnn

Defines a limit on the number of requests a daemon process should process before it is shutdown and restarted. Setting this to a non zero value has the benefit of limiting the amount of memory that a process can consume by (accidental) memory leakage.

If this option is not defined, or is defined to be 0, then the daemon process will be persistent and will continue to service requests until Apache itself is restarted or shutdown.

inactivity-timeout=sss (2.0+)

Defines the maximum number of seconds allowed to pass before the daemon process is shutdown and restarted when the daemon process has entered an idle state. For the purposes of this option, being idle means no new requests being received, or no attempts by current requests to read request content or generate response content for the defined period.

This option exists to allow infrequently used applications running in a daemon process to be restarted, thus allowing memory being used to be reclaimed, with process size dropping back to the initial startup size before any application had been loaded or requests processed.

deadlock-timeout=sss (2.0+)

Defines the maximum number of seconds allowed to pass before the daemon process is shutdown and restarted after a potential deadlock on the Python GIL has been detected. The default is 300 seconds.

This option exists to combat the problem of a daemon process freezing as the result of a rouge Python C extension module which doesn't properly release the Python GIL when entering into a blocking or long running operation.

shutdown-timeout=sss

Defines the maximum number of seconds allowed to pass when waiting for a daemon process to gracefully shutdown as a result of the maximum number of requests or inactivity timeout being reached, or when a user initiated SIGINT signal is sent to a daemon process. When this timeout has been reached the daemon process will be forced to exited even if there are still active requests or it is still running Python exit functions.

If this option is not defined, then the shutdown timeout will be set to 5 seconds. Note that this option does not change the shutdown timeout applied to daemon processes when Apache itself is being stopped or restarted. That timeout value is defined internally to Apache as 3 seconds and cannot be overridden.

source: http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top