5 ms·
> Systemd on the other hand has most of the things I need, but I found it cumbersome to use Could you please expand on this? From what I understand, to use sys
by MuffinFlavored 3y ago
> Systemd on the other hand has most of the things I need, but I found it cumbersome to use
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?
- ripley12 3y agoThat's 15 lines of configuration and 3 CLI commands to install a service. I have done this hundreds of times but I still need to keep a template around for unit files, I often forget to run `daemon-reload`, etc. 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.
- shardulaeer 3y agoI built the tool simply to improve developer experience. Run `systemctl list-units` and the console is flooded with a wall of services, most of them are not mine. Run `ser status` and I only see the ones that I created. The activity state, CPU and memory usage is displayed so I don't need to run a separate command. 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).
- MuffinFlavored 3y agoTo do formatting on a message (multilines of code, equivalent to ``` in Markdown), indent everything with 4 spaces
- shardulaeer 3y agoFixed, thanks for the heads up!
- MuffinFlavored 3y ago> The activity state, CPU and memory usage is displayed so I don't need to run a separate command. https://github.com/crazy-canux/awesome-monitoring https://github.com/crazy-canux/awesome-monitoring Check out Netadata + Nagios https://news.ycombinator.com/item?id=36944388 https://news.ycombinator.com/item?id=36944388 Check out this as well systemctl list-units | grep my-service
- fullstop 3y agoalso see systemd-cgtop
- markstos 3y agoAs long as remembering a new command is required this also be used: * 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".
- LoganDark 3y agoThe file's pretty cumbersome, honestly, since I usually don't remember the format or the best practices for it. 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.
- cpach 3y agoFWIW, you can override unit files that are installed by a package manager: https://hsm.tunnel53.net/article/systemd/ https://hsm.tunnel53.net/article/systemd/
- rcxdude 3y agoYou can even do this with 'systemctl edit <unit>' and it'll create a file in the right place for the override and show you the original contents for reference
- LoganDark 3y agoI think the "issue" isn't the package manager overwriting your custom unit files, but rather just the litter of untracked files in places the package manager is supposed to be in charge of. Since some people want to be able to track those files, and prevent them from making a mess. 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.)
- markstos 3y agoThis was solved from beginning of systemd with different directories for files mananged by package managers (under /lib), and files managed by you (under /etc). This is documented in `man systemd.unit`: https://www.freedesktop.org/software/systemd/man/systemd.unit.html 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.