1

I have wsgi file, where there is a line:

wsgi.py

if __name__ == "__main__":
    app.run()

But today my server didn't start and when I printed __name__, saw that it equals "wsgi" for no reason. I start my server like "sudo systemctl restart myserver.service"

myserver.ini

module = wsgi:app

master = true
processes = 3

socket = /var/www/myserver/myserver.sock
chmod-socket = 660
vacuum = true

die-on-term = true
logto = /var/www/myserver/server.log
enable-threads = true

myserver.service

Description=uWSGI instance to serve myserver
After=network.target

[Service]
User=savvasenok
Group=www-data
WorkingDirectory=/var/www/myserver
Environment="PATH=/home/savvasenok/MyServerEnv/bin"
ExecStart=/home/savvasenok/MyServerEnv/bin/uwsgi --ini /var/www/myserver/myserver.ini

[Install]
WantedBy=multi-user.target
Hamidreza
  • 1,465
  • 12
  • 31

1 Answers1

1

As it explains in here:

If the source file is executed as the main program, the interpreter sets the __name__ variable to have a value “__main__”. If this file is being imported from another module, name will be set to the module’s name.

So the reason is that you are running a python module (or file) which imports wsgi. In your case I think you imported wsgi to the /home/savvasenok/MyServerEnv/bin/uwsgi module which you sat as ExecStart and is being executed.

You can also check this answer for more information.

Hamidreza
  • 1,465
  • 12
  • 31