Trying VS Code's Terminal Loader instead of foreman or overmind
I did a video about debugging Rails in Visual Studio
Code a couple years ago that
showed off how to use the remote interface of the
debug gem with Rails 7's Procfile-based
bin/dev workflow. Using
foreman or overmind and the remote debugger interface is fine but it's
honestly no replacement for the developer experience of running binding.irb
directly against a dedicated terminal running nothing other than rails server.
So I decided to give this Terminal Loader extension a try to see if I could have my cake and eat it too: a one-shot way to run all of my development servers across multiple terminals. The verdict? It works!
- Install the extension
- Run the command
TLoader: Load Terminals(via Command-Shift-P) once, which will:- Launch a couple dummy terminals with split-views, which you can feel free to kill manually
- Create a
workspaceConfiguration/LoadTerminal.json, which you can (and should, IMO) add to.gitignore
- Edit the
LoadTerminal.jsonfile to specify which terminal groups you want to open, how many columns per group, and the commands to run for each one
This is my config for a straightforward Rails 7 app that runs the Rails server, the tailwind CLI, a Rails console, and Solid Queue. Because I don't typically need to interact with tailwind or my queue daemon, I relegated those to a shared terminal group. And while I didn't have need for it in this case, I appreciate that the extension allows you to set a different working directory for each terminal, which will be a huge boon to my projects that embed sub-libraries and example apps.
Here's my first crack at a LoadTerminal.json for this project:
{
"version": "1.2.1",
"groups": [
{
"name": "Rails Server",
"description": "Rails Server",
"enabled": true,
"terminals": [
{
"name": "server",
"path": ".",
"cmd": [
"env RUBY_DEBUG_OPEN=true bin/rails server -p 3000"
],
"num": 0
}
]
},
{
"name": "Rails Console",
"description": "Rails Console",
"enabled": true,
"terminals": [
{
"name": "console",
"path": ".",
"cmd": [
"bin/rails console"
],
"num": 0
}
]
},
{
"name": "Other",
"description": "Tailwind / Queue",
"enabled": true,
"terminals": [
{
"name": "tailwind",
"path": ".",
"cmd": [
"bin/rails tailwindcss:watch"
],
"num": 0
},
{
"name": "queue",
"path": ".",
"cmd": [
"bin/rake solid_queue:start"
],
"num": 0
}
]
}
]
}
Seems to work fine! Nice change of pace not having to juggle virtual-terminals-within-an-electron-wrapper-within-a-terminal anymore.