RE: VENV, Gunicorn, and Flask/Python Applications/BBBW

45 views
Skip to first unread message

Mala Dies

unread,
Sep 12, 2019, 10:17:45 PM9/12/19
to BeagleBoard
Hello,

I have been messing around w/ Gunicorn as a server to run my Flask/Python applications. Flask is a developmental server installation and needs to have another bound server to run in a undeveloped way. Right?

Anyway...

Flask = no production server
Gunicorn = production server for running Flask/Python applications

Okay...

I just found a way to use my virtual environment installs and source to run on boot w/ a .service file w/ systemd.

...


Okay so, it works. yea! But...the server keeps running even after I stop my .service file or disable it.

Seth

P.S. Does anyone know how to cancel their Gunicorn server from running online even after the .service file has been stopped/disabled?

Dennis Lee Bieber

unread,
Sep 13, 2019, 11:11:07 AM9/13/19
to beagl...@googlegroups.com
On Thu, 12 Sep 2019 19:17:45 -0700 (PDT), Mala Dies
<fun...@gmail.com> declaimed the following:


>Okay so, it works. yea! But...the server keeps running even after I stop my
>.service file or disable it.
>
>Seth
>
>P.S. Does anyone know how to cancel their Gunicorn server from running
>online even after the .service file has been stopped/disabled?

You may need to add an
ExecStop
line to the configuration. Can't help with what would be in that line

http://docs.gunicorn.org/en/stable/deploy.html#monitoring

has an entry for systemd...

[Service]
PIDFile=/run/gunicorn/pid
User=someuser
Group=someuser
RuntimeDirectory=gunicorn
WorkingDirectory=/home/someuser/applicationroot
ExecStart=/usr/bin/gunicorn --pid /run/gunicorn/pid \
--bind unix:/run/gunicorn/socket applicationname.wsgi
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true


though I'm not sure how $MAINPID gets set, especially as they appear to be
stuffing the PID into a file.



--
Wulfraed Dennis Lee Bieber AF6VN
wlf...@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

Mala Dies

unread,
Sep 13, 2019, 3:41:51 PM9/13/19
to BeagleBoard
Hello Mr. Dennis,

Thank you. That makes sense. I am unaware of PIDs but I guess I can check w/ the ExecStop= function.

Seth

P.S. I will test it and return service.

Mala Dies

unread,
Sep 13, 2019, 3:43:53 PM9/13/19
to BeagleBoard
Yes Sir,

I found the info. you were describing. You rule, matey!

Seth



On Friday, September 13, 2019 at 10:11:07 AM UTC-5, Dennis Lee Bieber wrote:

Mala Dies

unread,
Sep 13, 2019, 4:00:47 PM9/13/19
to BeagleBoard
Hello Again Mr. Dennis,

Seth here. Hey! You were right about ExecStop=. I typed it in and added this line:

ExecStop=/home/debian/virt/env/bin/gunicorn -b 0.0.0.0:5000 -w 4 MyPythonFile:app-shutdown

Seth

P.S. It takes a couple seconds to shutdown but it shuts down where my server is not online any longer. It stopped the workers and the file from running.


On Friday, September 13, 2019 at 10:11:07 AM UTC-5, Dennis Lee Bieber wrote:

Mala Dies

unread,
Sep 14, 2019, 9:23:17 PM9/14/19
to BeagleBoard
Hello Mr. Dennis,

You are not going to believe this idea. I was running another script on the same port. This is the only reason it did not work. Aw!

Seth

P.S. Sorry to bother you.


On Friday, September 13, 2019 at 10:11:07 AM UTC-5, Dennis Lee Bieber wrote:
Reply all
Reply to author
Forward
0 new messages