As enjoyable as it is to launch your development servers by hand, it takes time. And if you switch between projects several times per day that time accumulates. That is especially true if you need to launch multiple servers for each project, for example background workers.
You’re probably familiar with systemd already as it’s the default system for managing system-wide processes. However, not many are aware of how easily it can also be used to manage user processes.
Just create a configuration such as
myblog.service and leave it in
~/.config/systemd/user. The following snippet is a systemd configuration
for a jekyll dev server.
Every time you change or add a configuration file you’ll have to trigger
After that, you can start your user service.
As you can see, you need to pass the
--user flag. And this works without
sudo privileges, which is amazing.
Additionally, I allow dev servers that are not resource-hungry to run in the background continuously and start with the system.
For that, add a
WantedBy line in the
Install section of your service’s configuration
and enable your service.