david david - 1 year ago 153
Bash Question

How can I curl while django development server is running?

I have never ran into this before because I can always just run the dev server, open up a new tab in terminal and curl from there. I can't do this now because I am running the Django Development server from a Docker container and so if I open a new tab, I will be in the local shell and not the docker container.

How can I leave the development server running and still be able to curl or run other commands?

When I run the development server I'm left with this message:

Django version 1.10.3, using settings 'test.settings'
Starting development server at
Quit the server with CONTROL-C.

and so unable to type any commands.

Answer Source

You can use & to run the server as a background job in the current shell:

$ python manage.py runserver &
[1] <pid>

You can use the fg command to get back direct control over the runserver process, then you can stop it as usual using Ctrl+C.

To set a foreground process as a background job, you can pause it using Ctrl+Z, and run the bg command. You can see a list of running backgrounds job in the current shell using the jobs command.

The difference with screen is that this will run the server in the current shell. If you exit the shell, the server will stop as well, while screen uses a separate process that will continue after you exit the current shell.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download