Systemd and systemctl

# see https://www.freedesktop.org/wiki/Software/systemd/TipsAndTricks/

systemctl                           -> shows all active units
systemctl list-units --type=service -> shows all active services (--all to see loaded but inactive services too)
systemctl list-units --type=swap	-> shows swap unit configurations

# show cgroup tree
systemd-cgls

# services started by multi-user.target
systemctl show -p "Wants" multi-user.target | less

###################
# svnserve.service:
#
# sudo chown ************ bin/svnserve.service && sudo chmod 664 bin/svnserve.service && cp -v bin/svnserve.service /etc/systemd/system/ && sudo chown root: /etc/systemd/system/svnserve.service && sudo chmod 664 /etc/systemd/system/svnserve.service && sudo systemctl daemon-reload
# or
# sudo chown ************ bin/svnserve.service
# sudo chmod 664 bin/svnserve.service
# cp -v bin/svnserve.service /etc/systemd/system/
# sudo chown root: /etc/systemd/system/svnserve.service
# sudo chmod 664 /etc/systemd/system/svnserve.service
# sudo systemctl daemon-reload

# sudo systemctl status svnserve
# sudo systemctl enable svnserve
# sudo systemctl start svnserve
# journalctl -xe
# journalctl -xf

[Unit]
Description=Server for the 'svn' repository access method

# see https://www.freedesktop.org/software/systemd/man/systemd.unit.html#
# see https://www.freedesktop.org/software/systemd/man/systemd.special.html#
After=local-fs.target
Wants=local-fs.target

[Service]
Type=forking

User****
Group*********

RuntimeDirectory=svnserve
RuntimeDirectoryMode=750

PIDFile=/run/svnserve/svnserve.pid

# RuntimeDirectory is doing this:
# User****
# Group*********
# PIDFile=/run/svnserve/svnserve.pid
# PermissionsStartOnly=true
# ExecStartPre=/bin/mkdir /run/svnserve
# ExecStartPre=/bin/chown ************ /run/svnserve

KillMode=process
Restart=on-failure
RestartSec=3

# A shorthand for configuring both TimeoutStartSec= and TimeoutStopSec= to the specified value.
TimeoutSec=5

# -r root, --root=root
#	Sets  the  virtual  root for repositories served by svnserve.  
#	The pathname in URLs provided by the client will be interpreted 
#	relative to this root, and will not be allowed to escape this root.
ExecStart=/usr/bin/svnserve -d -r /mnt/1TB/DataWin_to_sync/SVNRepoLinux --log-file /********/apps/log/svnserve.log --pid-file /run/svnserve/svnserve.pid

[Install]
WantedBy=multi-user.target

######################
# couchpotato.service:
#
[Unit]
Description=CouchPotato
After=local-fs.target
Wants=local-fs.target

[Service]
Type=simple
User****
Group*********
RuntimeDirectory=couchpotato
RuntimeDirectoryMode=750
PIDFile=/run/couchpotato/couchpotato.pid
# KillMode=process
# Restart=on-failure
# RestartSec=3
TimeoutStartSec=60
TimeoutStopSec=15

# couchpotato.service: Supervising process 22342 which is not our child. We'll most likely not notice when it exits
#
# ExecStart=/usr/bin/python /********/apps/opt/couchpotato/CouchPotato.py --config_file /********/apps/etc/couchpotato.conf --daemon --data_dir /********/apps/opt/couchpotato_data --pid_file /run/couchpotato/couchpotato.pid

ExecStart=/usr/bin/python /********/apps/opt/couchpotato/CouchPotato.py --config_file /********/apps/etc/couchpotato.conf --data_dir /********/apps/opt/couchpotato_data --quiet

[Install]
WantedBy=multi-user.target

###################
# anytermd.service:
#
[Unit]
Description=A Terminal Anywhere
After=local-fs.target
Wants=local-fs.target

[Service]
Type=forking
PIDFile=/run/anytermd.pid

KillMode=process
Restart=on-failure
RestartSec=3
TimeoutSec=5

# anytermd.service: Main process exited, code=exited, status=1/FAILURE
#
# ExecStart=/********/apps/bin/anytermd --command "/bin/login -p adr" --port 23456 --user root --local-only
# ExecStart=/********/apps/bin/anytermd --command "/bin/login -p adr" --port 23456 --user root --foreground --local-only
SuccessExitStatus=1
ExecStart=/********/apps/bin/anytermd --command "/bin/login -p adr" --port 23456 --user root --local-only

[Install]
WantedBy=multi-user.target

################
# tomcat.service
#
[Unit]
Description=Apache Tomcat
After=local-fs.target network.target
Wants=local-fs.target

[Service]
Type=forking
WorkingDirectory=~
RuntimeDirectory=tomcat
RuntimeDirectoryMode=750
PIDFile=/run/tomcat/tomcat.pid
User****
Group*********
Environment=CATALINA_HOME=/********/apps/opt/apache-tomcat-7.0.64
Environment=CATALINA_PID=/run/tomcat/tomcat.pid
PermissionsStartOnly=true
ExecStartPre=/bin/rm -vf /********/apps/opt/apache-tomcat-7.0.64/logs/*
ExecStartPre=/bin/rm -vf /********/exifweb*.log

## KillMode=process
# Restart=on-failure
# RestartSec=3
TimeoutStartSec=60
TimeoutStopSec=15

# ExecStart=/bin/sh -c 'CATALINA_PID=/run/tomcat.pid /********/apps/opt/apache-tomcat-7.0.64/bin/startup.sh'
ExecStart=/********/apps/opt/apache-tomcat-7.0.64/bin/startup.sh
ExecStop=/********/apps/opt/apache-tomcat-7.0.64/bin/shutdown.sh

[Install]
WantedBy=multi-user.target

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.