0

I have two different python project placed in different folder (project 1 in pydir1 directory, project 2 in pydir2 directory).

Every time, I need to open two new terminal and run the python manage.py runserver command after change to the project directory.

Open 1st terminal window and

cd pydir1
python manage.py runserver 8000 

and then open 2nd terminal windows and

cd pydir2
python manage.py runserver 8001

Is there a easier way to do it, at the same time able to see the log progress in the terminal windows?

muru
  • 197,895
  • 55
  • 485
  • 740
  • You can do it, but how will you make sense of the combined log output? – muru Mar 11 '15 at 02:24
  • @muru I was looking at a command that will open two terminal windows and run it separately instead of manually open two terminal windows. However, I am open to any solution that can help me make it easier to do it. – user275517 Mar 11 '15 at 02:47

2 Answers2

2

You can use a single GNOME Terminal command:

gnome-terminal --tab-with-profile=Default --working-directory pydir1 \ 
  -e 'python manage.py runserver 8000' --tab-with-profile=Default \ 
  --working-directory pydir2 -e 'python manage.py runserver 8001'
  • The --tab-with-profile options open new tabs. (If you prefer windows to tabs, replace tab with window in the command.)
  • --working-directory saves you cd.
  • -e defines the command to be run in that tab. You can use custom profiles instead, and skip the -e ... part.

Save it as an alias, or create a custom launcher to simplify running this long command.

muru
  • 197,895
  • 55
  • 485
  • 740
0

I also recommend you to use inotifywait which is part of the package inotify-tools. After installing this package you can automatically restart your server whenever you saved a changed to your working directory. For example with the following script you can restart the server whenever you modify a source file:

while inotifywait -r -e modify pydir1; do
    # ...bash code to restart the server...
done