Published: July 28, 2022 • 2 min read
My development environment depends on several processes running. Here’s how I’ve scripted this setup.
Whenever I boot up, I need at least these processes running:
Here’s how I’ve scripted it:
#!/bin/bash tmux new-window -n sidekiq tmux send-keys -t sidekiq 'sidekiq' Enter tmux new-window -n rails tmux send-keys -t rails 'rails s' Enter tmux new-window -n webpack tmux send-keys -t webpack 'bin/webpack' Enter tmux new-window -n docker tmux send-keys -t docker 'bin/docker' Enter open http://host.docker.internal:3000/
This starts each process in its own named Tmux window, then opens the application in my browser. That last step is a losing race condition with the other processes, which are still booting, but I just wait a few seconds and refresh the browser tab.
Something I tried previously was opening each window with a command, like this:
tmux new-window 'rails s'
rails s to the new window, helpfully naming the window
The downside of this otherwise great command is that when the process
completes, the window closes. Kill your server once, and you lose the window.
There are more sophisticated approaches, but this gets the job done for a tricky dev environment. How do you script your application startup?
✉️ Get better at programming by learning with me. Subscribe to Jake Worth's Newsletter for bi-weekly ideas, creations, and curated resources from across the world of programming. Join me today!
Blog of Jake Worth, software engineer in Maine.