0

I setup mod_wsgi on my ubuntu/apache2 server.

I'm trying to run threads but daemons do not work.

When I try to run them in the background, nothing happens.

My wsgi script:

import sys, logging
sys.path.insert(0, "/var/www/xxx/public_html/blockchain/")

from app import app as application

logging.basicConfig(filename'/var/www/xxx/blockchain/wsgi.log', level=logging.INFO, filemode='w')

My xxx.conf file is:

Listen 8888
<VirtualHost *:8888>
        ServerName xxx.com
        ServerAlias xxx.com
        ErrorLog /var/www/xxx/logs/error.log
        CustomLog /var/www/xxx/logs/acccess.log combined
        WSGIDaemonProcess xxx user=www-data group=www-data processes=5 threads=10
        WSGIProcessGroup xxx
        WSGIApplicationGroup %{GLOBAL}
        WSGIScriptAlias / /var/www/xxx/public_html/blockchain/xxx.wsgi
        Alias /static/ /var/www/xxx/public_html/blockchain/static
        <Directory /var/www/xxx/public_html/blockchain>
                Order allow,deny
                Allow from all
        </Directory>

</VirtualHost>

The relevant part o my python script is:

if __name__ == '__main__':

    t1 = threading.Thread(target=doFirstThing, daemon=True)
    t2 = threading.Thread(target=doSecondThing, daemon=True)
    t3 = threading.Thread(target=doThirdThing, daemon=True)

    t1.start()
    t2.start()
    t3.start()

    app.run(host='0.0.0.0', port='8888', debug=True)

How can I make my threads work int he background when my Flask file is launched using wsgi.

Thanks

jennie788
  • 101
  • 1

0 Answers0