6 ms·
I really like systemd. My blog has a 10 line .service file. My app has a 10 line .service file. My load balancer has a 10 line service file. They're way less br
by nailer 11y ago
I really like systemd. My blog has a 10 line .service file. My app has a 10 line .service file. My load balancer has a 10 line service file. They're way less brittle than bash scripts would have been. Stdout automatically becomes logs with the service name attached. It's nice.
- ibrahima 11y agoUpstart is pretty similarly easy to use in my limited experience with it. Definitely a nice idea to have stdout just automatically go to a log file.
- justizin 11y agoBasically DJB did this in the 90s with daemontools, which many of us now use a revamped fork of called 'runit'. You still write shell scripts, but you also still have control. Again, I'm not entirely opposed to the ideas behind systemd, but I am opposed to basically every fucking Linux server distribution breaking because of things people are doing for the desktop, which began with upstart. There is also no love left to lose between me and sysV init scripts.
- nailer 11y agoI love djb's stuff - he has his own concepts of everything, though, including the FHS, which makes his stuff hard to run on regular Linux distros. If there was a djb Linux I'd definitely install it.
- vezzy-fnord 11y agosystemd has its own FHS requirements, as well: http://www.freedesktop.org/software/systemd/man/file-hierarchy.html http://www.freedesktop.org/software/systemd/man/file-hierarc... The only difference is acceptance.
- mercurial 11y agoBut Nixos, which doesn't follow the FHS, still uses systemd...
- vezzy-fnord 11y agoSure, much in the same way you can use daemontools without strictly following its FHS requirements. Or more likely you'd be using one of its many derivatives, as vanilla daemontools is rather old by now.
- justizin 11y agoYour system now has millions of more lines of code that few people understand which are vulnerable to privilege escalation, unfortunately. :/ I mean, you could just use Heroku, for free, most likely, to host what you are doing. Should all UNIX become Heroku? What happens if your blog starts doing a billion page views a day? When one of the systemd processes is taking up 95% CPU, what do you do? I'm not saying it's bad, I'm saying these are the type of concerns its' critics have. I am a fan of a lot of the ideas. I have downgraded several Linux systems which I needed To Work(tm) because of systemd being completely half-assed, and there are some great audits of its' code which make it appear to have been written by kindergarten students.
- deleted 11y ago[deleted]
- nailer 11y agoI'd take systemd over sysv init, atd, crond, three or four watcher daemons, syslog, various other semi-maintained tools that replicate each other's functionality, and around 30x 50-line shell scripts.
- vezzy-fnord 11y agoThere we go with the false dichotomy that just won't die again. It's pretty obvious you're not actually acquainted with the problem domain. Keep using whatever makes you feel comfortable, though.
- deleted 11y ago[deleted]
- vezzy-fnord 11y agoAnyone who brings up sysvinit and the "30x 50-line shell scripts" is clearly one whose perception is limited to the ad-hoc LSB-based sysvinit setups that once permeated GNU/Linux, but which have always been merely one relatively inefficient approach. Even back when Debian first introduced their sysv-rc, we already had IBM SRC, daemontools, simpleinit and NetBSD rc.d which showed different solutions. EDIT: Let me join in on the moaning about downvotes. Not that I understand why.
- hoodoof 11y agoCan you post your 10 lines for us to see?
- rsync 11y agoYes, please - genuinely interested.
- nailer 11y agoSure. [Unit] Description=Blah app [Service] ExecStart=/var/www/blah/bin/www Restart=always User=nobody Group=nobody Environment=PATH=/usr/bin:/usr/local/bin Environment=NODE_ENV=production WorkingDirectory=/var/www/blah [Install] WantedBy=multi-user.target
- heinrich5991 11y agoStarting as nobody is probably not a good idea if you have more than one service which does that. They'll be able to interact.
- hoodoof 11y agoCould you please explain in more details the issues here and the right way to do it?
- vacri 11y agoWith two applications running under the same user, if one is compromised, it has ready access to the other. Generally it's fairly easy to make a system user for an application if no special accesses are required - just make a custom system user for the application, and ensure it can access the various things it needs to touch (eg: logging).
- JdeBP 11y ago... and if you want to learn more than has been already said, start with the famous design of qmail as a collection of mutually untrusting daemons that run under individual unprivileged user accounts, precisely to insulate each from the others using the normal operating system mechanisms that insulate one user's processes, files, directories, and so forth from another's. A good question to ask yourself: "Presume that my daemon is compromised by an attacker ... * ... what processes can it trace, debug, read/write the memory spaces and environments of, or send signals to?" * ... what files, devices, and directories can it read and write?" * ... what files, devices, and directories does it own, and can thus grant access to?" Then ask: "How does the answer change if instead of all of my daemons running as the same (even if unprivileged) user they each run as different users, some (where appropriate) having no write access to anything and owning no files nor directories at all?"
- vezzy-fnord 11y agoOpenBSD: #!/bin/sh daemon="/usr/local/sbin/daemonx" . /etc/rc.d/rc.subr rc_cmd $1 Though, it's Korn shell, not Bash, I suppose. Reliable per-service logging was largely perfected by multilog. Judging complexity by observing external configuration is nonetheless exceptionally naive. One must factor in how the key-value pairs are built into an internal representation and dispatched, which is where things become an issue. Non-deterministic boot order (man 7 bootup) is one of many undesirable trade-offs.
- justizin 11y ago> Non-deterministic boot order (man 7 bootup) is one of many undesirable trade-offs. Yeah, also something I found annoying with Upstart's induction into Ubuntu. A predecessor at a place I worked at with a huge amount of traffic installed Ubuntu 9 on all of our memcache servers, and we found on a handful of other machines installed with Ubuntu 9 that non-deterministic boot order would randomly cause them to fail booting, and it was a coin-flip whether that would be a one-off problem or a forever problem requiring a reinstall. When you have 4 8GB machines (this was some years ago) powering memcache for a billion requests a day you don't really want a power cycle to cause 25% cache misses for hours as you wrestle with hardware and boot config. :/
- vezzy-fnord 11y agoUpstart doesn't have a formal dependency system, instead it orders things based on named preconditions and postconditions called events. Though these can be used to fulfill ordering requirements, I'd wager the information wasn't granular enough for parallelization to be efficient. Actually the main problem is that a lot of modern systems do not make their dependency graphs well observable, but instead treat them as in-memory ephemera that are constantly recalculated and cannot e.g. be written to persistent storage as known-good checkpoints. This is one area where s6-rc gets it right. You have to compile a manifest of your service dependencies and consistently boot from that well-known state, so for any changes it must be regenerated. serel was an earlier example of a service dependency system and parallel launcher which directly had you specify the nodes and edges of a directed graph as an RDF manifest. Clever.
- ck2 11y agoExcept you cannot extend them in any way, unlike a real bash script (init.d) Try having a dozen different types of config-test for different programs, there is no way to extend ala ExecConfigTest
- wstrange 11y agoIf you really want to wrap your service startup in a bash script, I don't think systemd precludes that approach.
- simoncion 11y agoBut, that's kinda the thing... Folks gush about how concise systemd unit files are. For services that require no complicated pre-start checks or configuration, equivalent service start scripts are more concise and just as legible in either OpenRC or -AIUI- Upstart. (Look at my conversion of a simple systemd unit file [0] to an OpenRC init script. [1]) What's more, for jobs that need complicated pre-start logic of one kind or another -AIUI- systemd provides no way to bundle that logic with your service description file. You have to put that logic in another script file which is then called by systemd. EDIT: I can't speak to Upstart, but even if your service has dependencies or needs to be started before or after some other service or class of service, [2] specifying them is similarly concise and legible. Add depend() { use some_optional_service need some_requred_service before some_service_or_service_class after some_other_service_or_srv_class } somewhere near the top of your script. For most services, this adds three non-whitespace lines. :) [0] https://news.ycombinator.com/item?id=10355588 https://news.ycombinator.com/item?id=10355588 [1] https://news.ycombinator.com/item?id=10357010 https://news.ycombinator.com/item?id=10357010 [2] For example: The network start scripts provide the "net" service. You might have a service that -for some reason- needs to start before or after the "net" service, but doesn't actually depend on it to start. This is what "before" and "after" are used for.
- mercurial 11y agoI love the systemd principles, as they were outlined by Poettering in the initial announcement. Configuration files instead of boilerplate shell script (and worse, shell script with special comments), socket-based startup, massive parallelism, cgroups, the end of PID files... I just wish systemd itself had stayed there and that the additional functionalities it keeps developing lived in separate projects with well-defined interfaces.
- vezzy-fnord 11y agoI find it disputable that parallelism is all that desirable. In systemd's case it requires the introduction of the dependency system with its multifaceted job queueing modes and transaction management that easily make up its most brittle edges, at least w.r.t. to its service manager, specifically. Seemingly innocuous configurations can result in cyclical transactions and dependency loops, and the internal graph engine bookkeeping these relationships provides very little debugging context at all. Considering parallelism is about startup optimization, a much better option is to load a process from a checkpoint image, e.g. one taken by CRIU or DMTCP.
- simoncion 11y ago> ...a much better option is to load a process from a checkpoint image, e.g. one taken by CRIU or DMTCP. Almost completely unrelated: Two things that came out of the LKML examination of kdbus during the 4.1 merge request were: 1) kdbus makes assumptions that break CRIU and similar projects 2) The kdbus people didn't seem to care much about this fact So... the "ultimate" systemd setup may very well preclude the use of process checkpointers to speed up startup. :(
- vezzy-fnord 11y agoWow, I wasn't aware of that. Do you have a reference?
- simoncion 11y ago
- _ak 11y agoThose are not unique systemd features. supervisor provides that, as well, without requiring to replace the init system underneath.