HOWTO Create a Service: Difference between revisions
From Pumping Station One
→Enabling Your Service: being consistant in my verbosity |
m Robot: Cosmetic changes |
||
| (5 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
== Why do it this way? == | == Why do it this way? == | ||
* Your service will be watchdogged by systemd | * Your service will be watchdogged by systemd | ||
* Your service will recover from network and power outages. | * Your service will recover from network and power outages. | ||
* It allows other | * It allows other members to help maintain your service, or disable it cleanly if it need attention. | ||
* It's great for IRC bots | * It's great for IRC bots | ||
| Line 21: | Line 21: | ||
sudo useradd strup -b /srv/ -m -r | sudo useradd strup -b /srv/ -m -r | ||
The creates a user named <code>strup</code>. The -b indicates the base home directory is /srv/, and therefore the system accounts home directory is /srv/strup/ | |||
== Working with SystemD == | == Working with SystemD == | ||
| Line 52: | Line 55: | ||
Initially, in my example, I see < | Initially, in my example, I see <code>ircbot: /home/PS1/hef/projects/strup/irc/main.cpp:45: int main(int, char**): Assertion `file.is_open()' failed.</code> because I havn't created a file yet. | ||
=== Working with Service Files === | === Working with Service Files === | ||
| Line 59: | Line 62: | ||
sudo su strup | sudo su strup | ||
Your are now running as the user ''strup'', but you are now in the user's home directory. Running <code>cd</code> without parameters will switch to the current user's home directory. | |||
cd | cd | ||
My example requires a file from project gutenberg. | My example requires a file from project gutenberg. | ||