How to add a new systemd unit on debian 8

I’m running the tiny tiny rrss webapp on my server. Last time I installed it, I used screen to daemonize the update_daemon2.php script to update the rss feeds. This time I wanted to do it right with a new systemd daemon (like suggested on the tiny tiny rss website). Sadly enough I didn’t find any debian related information how to add a new systemd unit. At last I found a community forum entry which describes this.

Beware: Maybe this is not the right way to do it ™. If you have a better idea how to manage this, please tell me!

  • Create a systemd unit file (e.g. ttrss.service) in the directory /lib/systemd/system
  • The file contains something likes this:

[Unit]
Description=ttrss_backend
After=network.target mysql.service postgresql.service

[Service]
User=www-data
ExecStart=/var/www/stefan/ttrss/public_html/update_daemon2.php

[Install]
WantedBy=multi-user.target

  • Create a symlink like that ln -s /lib/systemd/system/ttrss.service /etc/systemd/system/multi-user.target.wants/ttrss.service
  • Reload the systemd daemon systemctl –system daemon-reload
  • Start the systemd unit systemctl start ttrss.service

With the command systemctl status ttrss.service  you can monitor the activities of the service. It outputs something like this

ttrss.service – ttrss_backend
Loaded: loaded (/lib/systemd/system/ttrss.service; enabled)
Active: active (running) since Sun 2016-02-07 13:39:18 CET; 19min ago
Main PID: 948 (php)
CGroup: /system.slice/ttrss.service
└─948 php /var/www/XXXX/update_daemon2.php

Feb 07 13:57:45 v22016013319431489 update_daemon2.php[948]: [12:57:44/1371] cache/export: removed 0 files.
Feb 07 13:57:45 v22016013319431489 update_daemon2.php[948]: [12:57:44/1371] cache/upload: removed 0 files.
Feb 07 13:57:45 v22016013319431489 update_daemon2.php[948]: [12:57:44/1371] Removed 0 old lock files.
Feb 07 13:57:45 v22016013319431489 update_daemon2.php[948]: [12:57:44/1371] Removing old error log entries…
Feb 07 13:57:45 v22016013319431489 update_daemon2.php[948]: [12:57:45/1371] Feedbrowser updated, 78 feeds processed.
Feb 07 13:57:45 v22016013319431489 update_daemon2.php[948]: [12:57:45/1371] Purged 3 orphaned posts.
Feb 07 13:57:45 v22016013319431489 update_daemon2.php[948]: [12:57:45/1371] Removed 0 (feeds) 0 (cats) orphaned counter cache entries.
Feb 07 13:57:46 v22016013319431489 update_daemon2.php[948]: [12:57:46/948] [reap_children] child 1368 reaped.
Feb 07 13:57:46 v22016013319431489 update_daemon2.php[948]: [12:57:46/948] [SIGCHLD] jobs left: 0
Feb 07 13:58:27 v22016013319431489 update_daemon2.php[948]: [12:58:27/948] [MASTER] active jobs: 0, next spawn at 60 sec.

But again: If you know a better way how to do this with debian, please tell me!

Tags: , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: