Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to run Django on my Windows Server 2008 machine.

I can do this manually by calling python manage.py runserver 54321, which launches Django's server at http://127.0.0.1:54321 -- then I can use reverse proxy in IIS to feed the site through IIS.

But now, I want to automate this server launch so that it happens as soon as the server boots up. I'm using Scheduled Tasks to accomplish this. I have a file named launch.cmd which contains python manage.py runserver 54321 &, and then a scheduled task running under Local Service that runs launch.cmd at startup.

When I run the Scheduled Task to test it, it stops immediately with run result (0x1). Per the task history, this suggests that the script is being run and then ended immediately, meaning the Django server isn't around to serve content.

Is there a way to prevent my Scheduled Task from ending immediately after I launch my Django server?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

I would try running it as a different user to see if that is the issue. Also, you can try not using a batch file. Instead, set the location to python and use manage.py runserver 54321 as the parameters.

share|improve this answer
    
Running as a different user fixed it. Not sure why Local Service isn't acceptable. Thanks! –  Maxim Zaslavsky Mar 5 at 19:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.