[Answer]-Jenkins start django server after successful build

1๐Ÿ‘

I had the same problem.

Ken,

I tried using fabric, but again python manage.py runserver โ€“ runs continuosly, so the next command is not starting.

And just few mins ago my collegue showed me how to use nohup and with variable BUILD_ID of Jenkins it would be like this to get Success from the build and leave the Django server running:

BUILD_ID=dontKillMe nohup python manage.py runserver host_server &

This worked for our Django project testing.

๐Ÿ‘คxena_bcn

0๐Ÿ‘

Since you are using fabric to test, I would recommend defining another fabric task, say, deploy, which you could call assuming the build succeeds.

Much like the call to fab completes for a successful build such that you get to the nohup line, I would expect the deploy task to return also.

You may also want to consider making the server a service (either via an /etc/init.d style script, or upstart if Ubuntu), and have the fabric task stop the currently running one, copy over whatever new files it needs (or similar process), and then restart it.

Assuming what you have above is a bash script or similar, you may want to also define set -e so that, in case any of the commands returns a non-success code, the script will fail, and in turn, fail the build.

๐Ÿ‘คkhampson

Leave a comment