From eda7b263e621587ca1ffbbcdf724b13e110dd673 Mon Sep 17 00:00:00 2001 From: Sergi Delgado Segura Date: Fri, 20 Jan 2023 16:06:30 -0500 Subject: [PATCH] Adds teosd.service to run teos as daemon This builds on top of the work from the work by @decentralizedb and @jochemin. It is mainly just re-arranging the code and readmes to fit the reviews. Co-authored-by: decentralizedb Co-authored-by: jochemin --- INSTALL.md | 6 ++++- contrib/init/README.md | 42 +++++++++++++++++++++++++++++++++++ contrib/init/teosd.service | 45 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 1 deletion(-) create mode 100644 contrib/init/README.md create mode 100644 contrib/init/teosd.service diff --git a/INSTALL.md b/INSTALL.md index 35d422f..bb32bda 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -14,4 +14,8 @@ You can run tests with: cargo test ``` -Please refer to the cargo documentation for more detailed instructions. \ No newline at end of file +Please refer to the cargo documentation for more detailed instructions. + +# Systemd setup for backend + +Refer to [contrib](contrib/init/README.md) for a detailed explanation of how to set up your systemd service for `teosd`. \ No newline at end of file diff --git a/contrib/init/README.md b/contrib/init/README.md new file mode 100644 index 0000000..e627707 --- /dev/null +++ b/contrib/init/README.md @@ -0,0 +1,42 @@ +**This document guides you into how to set-up a systemd service to run `teosd`.** + +Since the teos service requires bitcoin to run, it is strongly recommended to also create a [system service for bitcoin](https://github.com/bitcoin/bitcoin/blob/master/contrib/init/bitcoind.service). + +Once you have set the bitcoin service, proceed to copy [teosd.service](teosd.service) to the systemd folder, that is, if running from this folder: + +``` +cp teosd.service /etc/systemd/system +``` + +You can also create a file called `teosd.service` in the systemd folder and copy the content of [teosd.service](teosd.service) to it: + +``` +sudo vim /etc/systemd/system/teosd.service +``` + +Notice the provided service file is using `teos` both as user and group for the service, so you may want to update that if that is not the configuration you are intending to use. Here are the lines to be updated: + +``` +[Service] +ExecStart=/home//.cargo/bin/teosd +SyslogIdentifier= + +# Directory creation and permissions +#################################### +User= +Group= +``` + +The next step is enabling the service. You can do so by running: + +``` +sudo systemctl enable teosd.service +``` + +Finally, you can start the service by running: + +``` +sudo systemctl start teosd.service +``` + +From that point on, the tower will be run every time your system is turned on, and restarted if needed. diff --git a/contrib/init/teosd.service b/contrib/init/teosd.service new file mode 100644 index 0000000..2fef183 --- /dev/null +++ b/contrib/init/teosd.service @@ -0,0 +1,45 @@ +[Unit] +Description=The Eye of Satoshi daemon +After=bitcoind.service network.target +Requires=bitcoind.service +Wants=network.target + +[Service] +ExecStart=/home/teos/.cargo/bin/teosd +StandardOutput=journal +StandardError=journal +SyslogIdentifier=teos + +# Process management +#################### +Type=simple +Restart=on-failure +TimeoutSec=300 +RestartSec=60 + +# Directory creation and permissions +#################################### +User=teos +Group=teos + +# Hardening measures +#################### +# Provide a private /tmp and /var/tmp. +PrivateTmp=true + +# Mount /usr, /boot/ and /etc read-only for the process. +ProtectSystem=full + +# Disallow the process and all of its children to gain +# new privileges through execve(). +NoNewPrivileges=true + +# Use a new /dev namespace only populated with API pseudo devices +# such as /dev/null, /dev/zero and /dev/random. +PrivateDevices=true + +# Deny the creation of writable and executable memory mappings. +MemoryDenyWriteExecute=true + +[Install] +WantedBy=multi-user.target \ No newline at end of file