Python Flask server as a windows background service using nssm

preview_player
Показать описание


In this video, we will learn how to run a python Flask server as a windows background service using nssm

Please subscribe, like and share this video

00:00 - Intro
01:34 - About nssm
02:05 - Install nssm
02:43 - system environment variable for nssm
04:18 - Example Flask server
04:55 - Step-1 Create batch file to run server
05:20 - Step-2 Setup nssm to run batch file as windows service
08:48 - Step-2 in action
12:05 - Automatic service startup on system startup
12:20 - Testing the flask application as a windows service
13:35 - Edit flask windows service with nssm GUI
15:15 - Commands to control windows background services
16:04 - Outro

#flask #nssm #background_service #windows_service #server #web #dev #tutorial #learning #beginners #pythonforbeginners #taming_python
Рекомендации по теме
Комментарии
Автор

Good video! Thats what i needed. Also good explanation, well done!

filipbottcher
Автор

Thank you so much for this detailed explanation of each point. This is what I exactly wanted

PrathapHosahalliGovindaNaik
Автор

awesome work. i was struggling with it. thanks a lot.subscribed

subhamthemusicalguy
Автор

Thank you so much. This was tremendously helpful :)

soumyashreeshinde
Автор

It was exactly what I needed. Thank you, it works perfectly. And very good explanation

elwanmayencourt
Автор

Thank you so much Sir for this insightful video. I am doing a project where I thought that creating a background process in windows might be helpful but I did not know the execution, which this video assisted me with. It has been really helpful and I hope that I can bring my project to fruition proceeding forward with this idea.

prateekbanerjee
Автор

good video, Can I Use this with fast api? i'm trying but i have a mistake no module found error 'click' but that module is installed

eduardobolivar
Автор

Thank you so much and i have a doubt which will work on django, fastapi also?

igqzhms
Автор

Everything is working well except that I am getting the following error when I start the service :
"' 'python' is not recognized as an internal or external command,
operable program or batch file."

shreyasmahajan
Автор

Hey what if my python flask has env, how do I make the call in the batch file?

jevoycharvis
Автор

'python' is not recognized as an internal or external command,
operable program or batch file.
in log file

bibekjoshivlogs
Автор

Excellent video. A question, I'm using 'waitress-serve --port=8081 hello:app' to run my flask server. In a machine with Windows 10, the service works well but in a machine with windows 7, the service donsn't work, the log says: "waitress-serve is not recognized as an internal or external command, executable program or batch file".
Any idea what the problem could be?

serranopink
Автор

for some reason, my local server will print hello world only if I'm running "run_server.bat" When I close cmd, I can see "my_flask_app" still running in Services but localhost50100 says "This site can’t be reached".
Please help.

minasalah
Автор

how do we add timestamps to the log file names via nssm ? Also is there a way to have timestamps for each new set of log statements for each unique run of the service in the log file via nssm without curating it via python?

cmfanz
Автор

It's completely working. But I want to run some application whenever I open the URL. So I added "os.system('notepad.exe')" in python code's function. So whenever I run the server manually from vscode and then open the URL in the browser, it will open Notepad in my OS. But whenever I try to do the same by starting the service and then I open the URL, it just keeps loading. And there is no log for that in the log file. It just keeps loading. Any idea on this?

arshitvaghasiya
Автор

Great tutorial, thanks for this. One thing missing here is how to run the service with a python virtual environment. I find the naive approach of altering run_server.bat to contain
call & python -m \path\to\app.py

Does work when run directly in cmd, but fails when called by nssm, with a log entry like:
"""
Unable to create process using -m \path\to\app.py'
"""
and no further information. Windows Event Viewer is similarly unhelpful: "0x0: Cannot create the process for package because an error was encountered."

chnadell