User: Password:
|
|
Subscribe / Log in / New account

Poettering: The Biggest Myths

Poettering: The Biggest Myths

Posted Jan 27, 2013 18:58 UTC (Sun) by apoelstra (subscriber, #75205)
In reply to: Poettering: The Biggest Myths by apoelstra
Parent article: Poettering: The Biggest Myths

Let me give a specific example. A week ago I wanted to set up a hunchentoot (lisp) web server, which involves starting a lisp instance, running some sort of setup lisp code, and leaving it running on some console somewhere.

Various Internet searches gave me 50-60 line init scripts for old versions of Ubuntu. These scripts were long and opaque and probably not even close to something that would run on Fedora 18. They relied on the detachtty tool (a minimal screen-type program) and did some sort of $PID dance around this. I wanted the server to restart whenever I killed it, so that I could reload the setup code that way. (Also I kept accidentally killing it by hitting Ctrl+D into screen.)

There's nothing out there about using hunchentoot with systemd. So, with maybe five minutes of searching manpages, I wrote

#======
User=lisp-web

[Unit]
Description=Run sbcl webserver session on a screen tty
After = syslog.target network.target

[Service]
User=lisp-web
Type=simple
ExecStart=/usr/bin/screen -D -m /bin/sbcl --load-path /home/lisp-web/ --load default-server.lisp
Restart=on-success
#======

Short, simple, clear, works correctly, tells me when things go wrong, etc, etc. I can connect to screen and hit Ctrl+D to reliably restart the server. It never hangs or gets out of sync or leaves ports in use or files locked.


(Log in to post comments)

Poettering: The Biggest Myths

Posted Jan 27, 2013 21:11 UTC (Sun) by pizza (subscriber, #46) [Link]

This "thread" finally motivated me to write a systemd unit file for my photo organizer's background threads. I don't know why I put it off so long.

It took me under five minutes. Would have been less time if the Fedora 16 server it's running on had a more modern systemd installed.


Copyright © 2017, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds