Systemd tips

How to make them do what you want, not to rant on about. Slashdot is better for rants anyway.

Systemd tips

Postby Doug Coulter » Thu Oct 25, 2018 3:38 pm

Or something. Systemd has been a royal PITA for me, as I did a lot of serious customization - my own daemons, special mounts of remote stuff, basically every system around here is heavily customized....and when systemd first started being forced upon us, things like mounting a remote share didn't work if you were using wifi - that's right, the old put it in /etc/fstab thing that worked forever and was smart enough to wait to see if you'd get connected was broken by red hat's (Lennart Poettering) thing that was suppose to make things more reliable and better sequenced on boot. Of course, not....and LPs arrogant response was "that was never reliable, don't try it EWONT_FIX". Except it WAS reliable, and the workarounds on google did work - till the next version of systemd came along in updates, and then those old workarounds generated hung systems that wouldn't boot (real nice for remote headless boxes)...and on and on. I'll skip the other tales of woe for now..it's getting stable now and well, you gotta work with the enemy you know.

I had something new fail, again it'd be nice if things you find on google had dates and stuff so you'd know if they were maybe obsolete -
The "service" command used to start and stop services initially got redirected to the equivalent systemctl command and noted that on your terminal.
I never saw that notice myself - I just found an obsolete google ref to it - and now, it doesn't work anyway, being for one of the older init systems.

And....systemd daemons don't have to be daemons....now. In fact, bringing over your old ones that carefully forked off is now a bad thing. And it bit me on the ... along with the service command as I was editing something and expecting it to, you know, stop when commanded and then restart with the edited version, instead of ignoring the service stop command but paying attention to the restart one...resulting in multiple daemons writing to the same mariadb database and weird error messages that took awhile to figure out....

I've had so much of this stuff happen in my increasingly sophisticated infrastructure here that I started another BBS internally since it'd be a lot of clutter here, and harder to search among the other content here. But...this one's worth copying over.

//////////////////////////////////////////////////// copy from internal phpbb

Be sure and check the man pages on HC21...made with the script below.

New style daemons don't need to daemonize....!!!!!!!!!!!!!!!!!!! and in fact it screws up some things in systemd (as usual found out the hard way)
https://www.freedesktop.org/software/sy ... aemon.html

Don't use sudo service start/stop etc - that's from init or upstart and no longer redirects to systemctl - and sometimes won't work or do as you expect.

Here's a neat little script I wrote to make man pages into pdfs because the terminal UI for man is horrible.
If two arguments, the first is the section number (just like plain man)
This will sometimes show an error because some font it wants isn't there. Works beautifully even so. Just check the pretty .pdf.
I put the results on a share here for later on. Most of these are too big to print and use that way, and as far as I know man doesn't have meaningful internal seach in results, but pdf does and that's a huge deal.


#!/bin/bash

# man2pdf script

# fairly cheesy existence test and assume
# args are reasonable - no error checking
if [ $2 ]
then
FILE=($2.ps)
else
FILE=($1.ps)
fi
echo "file: $FILE"
man -t $1 $2 >> $FILE
ps2pdf $FILE
rm $FILE
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Systemd tips

Postby Doug Coulter » Thu Oct 25, 2018 8:12 pm

Just wanted a link here to reply to the systemd lovers who accuse me of not wanting to learn just one simple command....
https://xkcd.com/1168/

Otherwise known as:
tar.png
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Re: Systemd tips

Postby Donovan Ready » Fri Oct 26, 2018 2:16 pm

I think next time (if) I install a new box I'll use BSD... At least the flight manual is like real UNIX...
Donovan Ready
 
Posts: 239
Joined: Thu Apr 17, 2014 1:22 pm
Location: Austin, Texas

Re: Systemd tips

Postby Doug Coulter » Fri Oct 26, 2018 2:58 pm

Hard call. I have a couple friends who use BSD (old bellheads with JCL by heart etc). Seems good for some stuff, but...if you want crazy stuff like modern sensor libraries for a raspberry pi...not happening. Their main use now seems to be for a NAS since BSD has zfs (IIRC) that lets you do snapshots fast (that amount to fast differential backups) so as to convince yourself that simply having multiple copies is a waste of money. Well, I don't buy that one - I've had a drive fail and I don't care how damn clever the file system is, and I've had a dev working here get pissed and erase stuff that no raid could recover...I like what I did instead - multiple rolling backups dispersed across time and space, disks are damn cheap now (see my notes about using odroid HC2's as NAS - I'm doing it with both Open Media Vault {for dummies who just want NAS and don't try their flakey plugins} and plain old full boat linix so they can mount each other, do scripts and serve my home version of PHPBB (which I wish I could afford to put up here too and find a way to mirror easily - it's different content than most of what's here - it's my notes, tips and tricks for making computers dance to my tune).

I almost can't count the ways systemd made my life miserable for a couple of years...but it seems to have settled down for the last 6 months or so, and while that cartoon is more than appropriate ( but heck it should have been an rsync command...)... there are now documents out for systemd and helpers that actually match the reality, the big bugs that really killed me are fixed, and now, while I don't exactly *like* it, I'm OK with it and am willing to since I get all the other things good from debian and pals that way. Other than pulse audio - Lennart's other disaster, which Debian has dropped from raspberry pi distros because, in LP's words - "it exposes existing weaknesses in audio drivers" - eg, it again breaks userspace. I wish Linus could revert or more for a little bit and give this guy a classic tongue lashing - it'd make a zillion bucks on pay per view. Like the classic "I don't understand how you are alive, you're so dumb I wonder how you found a tit as a baby." classic-level.

At any rate, it's now the devil I know, or at least enough that all my old stuff that it broke now works again, and I can reliably code new stuff that works with it.

I should have included the pdf's I made that helped me there, and maybe some other notes...while not a huge fan of pdf, at least it's readable, searchable and multiply viewable (more than one part at a time) which helps me at least. When the man command chops a 3 digit page document up into a ton of 1/3 pages, comprehension can get a little tough.

The main one. Key point is you put your .service file in /etc/systemd/system and do sudo systemctl name enable to have it make a link to where it goes, most often that will be /etc/systemd/system/multi-user.target.wants/thename.service. Start starts the thing right now and so on. Just some odd new things to know about how to construct that .service file for your widget.
systemctl.pdf
system control
(64.25 KiB) Downloaded 221 times

So here's that one:
sysd_service_file.pdf
some info on service files
(63.23 KiB) Downloaded 225 times

No, I'm not going to cheerlead for this stuff. I was used to using the regular system logs and putting debug into some log file of my own in my home to debug these things I write. But this can work and it does work for me - now, finally.
journalctl.pdf
And when it doesn't work...
(41.14 KiB) Downloaded 232 times

Now that "have you tried journalctl -xe yet? thing you see on all the questions makes sense. Funky log formats suck, but....

What's nice for me is that my perl (or other) utilities now run without change on everything here that runs linux - 32, 64 bit, arm, x86, wifi, wired, standalone - it just works (well, shares don't work without some connection for commands and data but you get the idea).

But hey, if you try BSD, let us know how it plays out and what you can do with it that's cool. I have no animosity towards it - and the far smaller community can be an advantage as well as a weakness - less crap. A few die-hard fans can be better than a ton of "likes" types.
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA


Return to Operating systems

Who is online

Users browsing this forum: No registered users and 5 guests