Posted on • Originally published attech.serhatteker.com on
Run Multiple Make Targets Concurrently
make is a widely used and powerful tool for running common tasks in a project.
I often look at theMakefile
of a project in order to see how a project perform regular tasks such as running tests, compiling and starting db, etc.
Use Case 1
I want to run 2 local servers at the same time. I can run them on separate terminal windows but I don't want to do that. I'm a lazy developer and want to useone line solution.
For instance I want to run apython
backend server andjavascript
front end server forlive reload
— if there is any change in static assets likejs
,css
,scss
etc..
# Makefiledjango-server:## Run the Django serverpythonmanage.pyrunserver8000npm-server:## Run npm server to live reload npm run dev
You can run them concurrently like below:
$make-j 2 npm-server django-server
Or you can use atarget
for it as well:
# Makefileservers: make-j 2 npm-server django-serverdjango-server:## Run the Django serverpythonmanage.pyrunserver8000npm-server:## Run npm server to live reload npm run dev
Then runmake servers
.
Use Case 2
I want to run a local server and open a browser related to it. I don't want to manually click my browser and typelocalhost:$PORT
.
Solution:
# Makefilelocal-dev:django-server browserdjango-server:## Run the Django serverpythonmanage.pyrunserver8000browser: google-chrome--new-window http://localhost:8000# or if you use firefox# firefox --new-window localhost:8000
Then typemake local-dev
.
All done.
Top comments(1)

I think you could achieve the same result just using the shell, as follows-
python manage.py runserver 8000 &
google-chrome --new-windowlocalhost:8000 &
or more economically-
nohup python manage.py runserver 8000 &
nohup google-chrome --new-windowlocalhost:8000 &
because you could then close the terminal
For further actions, you may consider blocking this person and/orreporting abuse