6
votes

I want to run "python manage.py runserver" from a bash script

First if I wanted to run from a terminal "python manage.py runserver &" but it doesn't work. I found the fix for this in (https://code.djangoproject.com/changeset/16327). Manually in a terminal running "python manage.py runserver &" works fine. I've added in a bash script "python manage.py runserver &" but it doesn't start the server.

Error:
File "/usr/local/lib/python2.7/dist-packages/Django-1.3-py2.7.egg/django/utils/autoreload.py", line 137, in main
    reloader(main_func, args, kwargs)
  File "/usr/local/lib/python2.7/dist-packages/Django-1.3-py2.7.egg/django/utils/autoreload.py", line 110, in python_reloader
    reloader_thread()
  File "/usr/local/lib/python2.7/dist-packages/Django-1.3-py2.7.egg/django/utils/autoreload.py", line 89, in reloader_thread
    ensure_echo_on()
  File "/usr/local/lib/python2.7/dist-packages/Django-1.3-py2.7.egg/django/utils/autoreload.py", line 77, in ensure_echo_on
    attr_list = termios.tcgetattr(fd)
termios.error: (25, 'Inappropriate ioctl for device')
2
Why oh why oh why not just use a normal deployment mechanism... - Ignacio Vazquez-Abrams
I want to run this command from a job in Hudson (Add Build Step -> Execute shell). After the server is started run nosetests - Sorin M
That is the wrong way to do it. Unit tests - including nose - should use the built-in test server and client from the code, not access the actual development server. - Daniel Roseman
@Daniel My goal is to have a Hudson job that is doing the following: update sources from SVN, start selenium server jar, run server "python manage.py runserver" (This is my problem) , run Selenium automated tests using command nosetests --with-xunit --xunit-file=nosetests.xml - Sorin M

2 Answers

6
votes

The problem is probably that hudson is not running as your user... you could run

source /home/your_user/.bashrc && django_serve 

to make it run that alias, but I think you'll probably need to switch users

-- or --

have hudson run the dev server from it's own checkout of the source

Edit: Looking at your erro though, I think this may solve your problem:

instead of

python manage.py runserver

try adding the --noreload flag to disable the auto reloader

python manage.py runserver --noreload
0
votes

I use alias to start django server. May be can help)

Just add alias django_serve="python manage.py runserver &" at the end of your ~/.bashrc or ~/.profile.

Also you create .bash_aliases and place your aliases into this file and execute it before you make any actions like


if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi