by MuffinFlavored · 3y ago · 0 comments
Could you please expand on this? From what I understand, to use systemd to deploy a microservice is basically one file:
# /etc/systemd/system/myservice.service
[Unit]
Description=My Microservice
After=network.target
[Service]
ExecStart=/path/to/myservice
Restart=always
User=myuser
Group=mygroup
Environment=VARIABLE=value
WorkingDirectory=/path/to/service/directory
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=myservice
[Install]
WantedBy=multi-user.target
Then, to "use" it: # reload systemd
sudo systemctl daemon-reload
# start service
sudo systemctl start myservice
# enable service at boot
sudo systemctl enable myservice
# check status
sudo systemctl status myservice
# check logs
journalctl -u myservice
What more advanced stuff were you trying to do that you ran into that made systemd seem cumbersome? hp@hp:~$ ser status
+-----+-------------+----------+----------------+-------+--------+
| pid | name | active | enable on boot | cpu % | memory |
+-----+-------------+----------+----------------+-------+--------+
| 0 | hello-world | inactive | false | 0 | 0 |
+-----+-------------+----------+----------------+-------+--------+
| 0 | index.js | inactive | false | 0 | 0 |
+-----+-------------+----------+----------------+-------+--------+
Another UX improvement is the template generation. I found myself googling it everytime. I f there is something more custom (etc sockets) I can use the `ser edit`, this will open nano with a pre-populated template that I can edit.Finally why limit oneself to systemd? pm2 runs on Mac and windows, I aim to do the same. Same set of commands to create services everywhere, with details abstracted away (easier said than done, need to look into their APIs).
https://github.com/crazy-canux/awesome-monitoring
Check out Netadata + Nagios
https://news.ycombinator.com/item?id=36944388
Check out this as well
systemctl list-units | grep my-service* systemctl status 'brand-*' That is, custom services could start with the same prefix.
I run a lot of custom services, and usually I want to check on one specifically, or if I want to look at the total service health, I also want to include the services which are "not mine".
Plus, sometimes there is no place to put them that isn't conflicting with the package manager, so "best practice" ends up being to make your own package containing the unit file, and ...
I'm not a big fan of "best practices" in general, but it'll turn into a whole rabbithole if you let it. At least with a piece of software like this, you just run a few commands and it remembers, and you get tons of sane defaults.
https://www.freedesktop.org/software/systemd/man/systemd.uni...
The same doc also describes a "drop-in" file format, where you can override just the details you want from a system file.
In practice I don't think it is a huge issue. I've just left unit files laying around on embedded devices without issue. Hard to find which ones are mine though, if I've lost my mental list of them.
(Also, writing one from scratch without a template is annoying, since I haven't memorized the format.)
I like systemd but I can see a lot of value in friendlier tools like this. What I really want is a TUI tool like Lazydocker for managing systemd services.