Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Serhat Teker
Serhat Teker

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
Enter fullscreen modeExit fullscreen mode

You can run them concurrently like below:

$make-j 2 npm-server django-server
Enter fullscreen modeExit fullscreen mode

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
Enter fullscreen modeExit fullscreen mode

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
Enter fullscreen modeExit fullscreen mode

Then typemake local-dev.

All done.

Top comments(1)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss
CollapseExpand
 
rdurkacz profile image
rdurkacz
  • Joined

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

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Uomo Universale | Software Engineer | Entrepreneur | builds systems | py:go:js |
  • Location
    127.0.0.1
  • Work
    Software Engineer
  • Joined

More fromSerhat Teker

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp