TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Systemd by Example (2021)

290 点作者 emigre大约 1 年前

19 条评论

doix大约 1 年前
Ha, systemd is basically my git. I&#x27;m always surprised by how many developers don&#x27;t grok git despite understanding significantly more complex things. I keep thinking if they would just take a day or two, they would get it and then wouldn&#x27;t complain about having to copy paste commands and &quot;rm -rf &amp;&amp; git clone&quot; to fix their workspaces.<p>And yet I do the _exact_ same thing with systemd. I don&#x27;t get it, I don&#x27;t like it, and every time I need to do _anything_, I&#x27;m googling, copy pasting commands into my terminal until something vaguely correct happens. The CLI options are indecipherable to me, like reading hieroglyphics.<p>Deep down I understand that it solves some pretty complex things when it comes to system initialization, but something about the UX of using journalctl and systemctl is so bad (for me) that it creates a mental block that I cannot overcome.<p>Luckily, nothing I do in my day job requires messing with systemd.
评论 #39383467 未加载
评论 #39383777 未加载
评论 #39384796 未加载
评论 #39383100 未加载
评论 #39389821 未加载
girvo大约 1 年前
I was finally impressed with systemd when I recently had to port our single-process multi threaded TCP&#x2F;UDP server (listening on a heap of ports) at work to a multiple binary&#x2F;process, single threaded asynchronous IO system.<p>PartOf= let us still have one top level “lithium” service to start and stop which starts and stops all of the other services, while being able to use journalctl to view them as one log file via a wildcard!<p>Super nice, it’s been quite lovely.
hiAndrewQuinn大约 1 年前
Systemd is a pretty neat little thing. It&#x27;s what keeps me running Ubuntu and Debian servers instead of switching to Alpine, at least in those situations where I can&#x27;t containerize what I want to do.<p>The thing that got me into it was systemd timers. I really like being able to split up <i>what</i> should run from <i>when</i> should it run. `cron` works best if you desire simplicity above all else, and Slack used `cron` for a very long time before moving to something more custom. But I ultimately don&#x27;t feel like the learning curve for systemd timers is that bad, and the benefits it can bring (like writing all your echo statements to journalctl instead of some random hard coded logfile in a script) feel very worth it to me.
评论 #39380515 未加载
评论 #39380755 未加载
评论 #39380723 未加载
dang大约 1 年前
Related:<p><i>Systemd by Example</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=36817510">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=36817510</a> - July 2023 (11 comments)<p><i>Systemd by Example</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=30071240">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=30071240</a> - Jan 2022 (69 comments)<p><i>Systemd by Example – The Playground</i> - <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=30070159">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=30070159</a> - Jan 2022 (1 comment)
gradschool大约 1 年前
I wish I could make friends with systemd like y&#x27;all. I spent at least a week wrestling unsuccessfully with systemd (admittedly starting from complete ignorance) to make a service that synchronizes a local directory on a laptop with a remote directory on a server after a docker container is stopped but before the filesystems and network stack are torn down during poweroff. It was easy enough to accomplish by manually invoking a script prior to powering off but no amount of cajoling, poring over documentation, or reading and adapting examples from forum posts on my part would get systemd to do it automatically without conflicts, race conditions, or timeouts. Is this not exactly the kind of problem systemd dependences are intended to solve?
评论 #39383447 未加载
评论 #39382325 未加载
braincat31415大约 1 年前
From the personal experience, systemd works quite well when it works, but sometimes I ran into problems with it that were very hard for me to solve. I admit I never became a systemd expert, but I think I had a decent working knowledge of it.<p>This was the final straw though: <a href="https:&#x2F;&#x2F;forums.debian.net&#x2F;viewtopic.php?t=154562" rel="nofollow">https:&#x2F;&#x2F;forums.debian.net&#x2F;viewtopic.php?t=154562</a><p>I am back to sysvinit and happy.
Emigre_大约 1 年前
The blog post series author then did an online playground [1] that lets you create systemd examples and experiment with systemd in the browser. It&#x27;s really interesting.<p>[1] <a href="https:&#x2F;&#x2F;systemd-by-example.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;systemd-by-example.com&#x2F;</a>
shdh大约 1 年前
A lot of people still probably hate on systemd, but it and journalctl are pretty nice to me.
评论 #39381038 未加载
评论 #39387727 未加载
smetj大约 1 年前
This doc format works best for me ... just enough to get you started and get results. Digging deeper can be done where required. More like this!
评论 #39380210 未加载
andrewstuart大约 1 年前
Systemd is one of the things that is really enhanced by ChatGPT.<p>“Write me a service to start this program”<p>Or<p>“Write a socket activated service to…..”<p>Or<p>“Write a systemd timer that runs every ten minutes”<p>Etc etc
评论 #39383290 未加载
评论 #39383388 未加载
wrs大约 1 年前
I haven’t been in the weeds with systemd for a while, but this post was very helpful in understanding how systemd <i>actually works</i>, which didn’t match my (or, I would think, nearly anyone’s) intuition as a user of it. I don’t know if there’s any other full technical explanation of how units, jobs, transactions, etc. are actually handled.<p><a href="https:&#x2F;&#x2F;blog.darknedgy.net&#x2F;technology&#x2F;2020&#x2F;05&#x2F;02&#x2F;0&#x2F;index.html#tech-critique" rel="nofollow">https:&#x2F;&#x2F;blog.darknedgy.net&#x2F;technology&#x2F;2020&#x2F;05&#x2F;02&#x2F;0&#x2F;index.htm...</a><p>&gt;systemd’s developers and almost all public documentation revolve around a “unit-centric” definition of systemd (except when discussing bugs), but my position is that for systemd-the-service-manager the most important construct is not the unit but the job, and hence one ought to understand systemd in a “job-centric” way.
SuperNinKenDo大约 1 年前
Took me a while to read through so I could come back and comment.<p>I&#x27;ve got to say, this is probably the best single explainer of the basics of systemd I&#x27;ve read.<p>I&#x27;ve only recently started fiddling with systemd extensively since I had my Linux-coming-of-age prior to its widespread adoption. I&#x27;ve got to be honest. I&#x27;ve found the experience very confusing and disorientating. The man pages feel really terse, even by manpage standards, and all the information is heavily split up so it&#x27;s quite difficult to build a mental model of the full system IMO.<p>Somethint like this would have been magic before, but it was still really helpful to me now with the way it explained things, I feel like it took me most of the way from cargo culting, into more understanding.<p>Great write-up!
js2大约 1 年前
&gt; Now we need to tell systemd to execute halt.service when it reaches halt.target.<p>The halt service, along with poweroff, reboot, and kexec get special treatment:<p><a href="https:&#x2F;&#x2F;www.freedesktop.org&#x2F;software&#x2F;systemd&#x2F;man&#x2F;latest&#x2F;systemd-halt.service.html" rel="nofollow">https:&#x2F;&#x2F;www.freedesktop.org&#x2F;software&#x2F;systemd&#x2F;man&#x2F;latest&#x2F;syst...</a>
andrewfromx大约 1 年前
funny, to me systemd == no docker, no containers, just a VM.<p>it&#x27;s my goto way to keep my programming running and have it be restarted if the vm reboots. I use VMs like &quot;pods&quot;. I deploy code directly to the VM and run it there along with other programs. I scale up and scale down with: <a href="https:&#x2F;&#x2F;www.pulumi.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.pulumi.com&#x2F;</a>
评论 #39381033 未加载
CyberEldrich大约 1 年前
“Systemd .. reminds me of every overly convoluted script a junior coder has ever written”<p><a href="https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;linux&#x2F;comments&#x2F;bsunzw&#x2F;systemd_vs_init_scripts_an_essay&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.reddit.com&#x2F;r&#x2F;linux&#x2F;comments&#x2F;bsunzw&#x2F;systemd_vs_in...</a>
znpy大约 1 年前
Back in the day when LinuxAcademy was still cool, I asked for a systemd course... and they did it. Can&#x27;t find the link right now, but that was what made systemd really click for me.<p>Weird that still there is no apress&#x2F;o&#x27;reilly&#x2F;packt&#x2F;manning introductory book about systemd.
评论 #39381658 未加载
zokier大约 1 年前
Personally I find systemd man pages pretty great, they comprehensively explain pretty much every thing that you need to know. Sure, they are more of a reference than a tutorial and there is lot of material to read there, but still I&#x27;d recommend reading the relevant sections whenever you are working with systemd<p><a href="https:&#x2F;&#x2F;www.freedesktop.org&#x2F;software&#x2F;systemd&#x2F;man&#x2F;latest&#x2F;systemd.html" rel="nofollow">https:&#x2F;&#x2F;www.freedesktop.org&#x2F;software&#x2F;systemd&#x2F;man&#x2F;latest&#x2F;syst...</a>
评论 #39381826 未加载
kosolam大约 1 年前
I like it
traverseda大约 1 年前
I am not having a good time with systemd on my embedded device.<p>Somewhat complicated scenario, I need to change the mode of a wifi driver (which I do via modprobe), use iw to create a second interface for that wifi device, and finally use networkmanager to create a wifi hotspot based on the host name of the device. We set the hostname based on the mac address of wlan0.<p>There are a lot of places this can go wrong, and you need a lot of deep knowledge of systemd to get it right.<p>I start with three services, one to set the hostname, one to create the wlan0_ap device, and one to start up the wifi hotspot using nmcli.<p>Alright, simple enough, this is the kind of thing systemd is good at, right?<p>Well no, (and pardon me if my memory isn&#x27;t perfect on this, it&#x27;s tricky to debug weird race conditions) sometimes setting the hostname fails. Why? Well sometimes wlan0 doesn&#x27;t exist, there&#x27;s a udev rule that renames wlan0 during start up. Apparently I can add the systemd tag to that udev rules, and it will create a `.device` dependency I can Require. Alright, use both require and after keywords just to be sure. Good enough.<p>Huh, onehsot services are listed as stopped even though they&#x27;ve run. Do some research, find out I need the `RemainAfterExit` keyword yet. Sure, dependencies are working.<p>Now wlan0_ap device creation sometimes fails. Why? No really, why, this is hard to debug. Well looking around at dmesg it <i>looks</i> like the problem is that networkmanager is trying to do something with the device at the same time I am. Looks like it&#x27;s enumerating device capabilities at the same time I&#x27;m trying to create a new device? Oh well, I&#x27;ll just add the retry keyword to my service.<p>Oh, wait, I can&#x27;t add the retry keyword to one-shot services? Really? Internet tells me to change the service type to simple. Sure, we&#x27;ll try that. Now that wlan0_ap device exists, let&#x27;s start our access point.<p>Also it&#x27;s still sometimes failing on the hostname step still? The set-hostname command is asynchronous I think? I&#x27;ll add a line to the start_access_point script that waits until the hostname isn&#x27;t the default.<p>Everything is looking good. Oh wait, it&#x27;s sometimes failing intermittently. What the hell, why doesn&#x27;t wlan0_ap exist? Service type `simple` considers a service to be started when the command first launches, not when it exit successfully. I&#x27;ve introduced another race condition.<p>How can I make a service that works like a oneshot, but that you can retry? What, write a shell script and use systemd-notify to say it&#x27;s complete?<p>Long story short I ended up just writing a traditional shell-script based init script. Maybe I&#x27;m thinking about systemd wrong or something.
评论 #39382249 未加载
评论 #39391395 未加载