0

Following this answer you can register a python script as a windows service with NSSM.
But are there any obvious downsides on registering a django management command as windows service this way?

nssm.exe install ProjectService 
nssm.exe set ProjectService Application "c:\path\to\env\Sricpts\python.exe"
nssm.exe set ProjectService AppParameters "c:\path\to\django_project\manage.py command"

The command would parse the contents of some files as they are being created.

kokoi
  • 35
  • 1
  • 6

1 Answers1

0

Not any downside that I can imagine that wouldn't also exist if you wrote a script to do it. In theory you could be loading too much, for example if you don't need database access or your models in order to complete whatever is in that command, perhaps break it into a script and call that directly with python. Otherwise, enjoy the convenience and see if you can identify a downside and try to solve that directly.

If you find yourself wanting to schedule tasks that run for a variety of times you might want to try a distribute task queue pattern which you can adopt quickly using https://github.com/Koed00/django-q or something like it.

stormlifter
  • 3,781
  • 3
  • 17
  • 20
  • Thank you for your answer. I agree with you, the main reason to use the command instead of a python script was django's model api. – kokoi Jan 17 '21 at 10:42