Merge pull request #45 from marcinja/2020-02-add-systemd-service

Add systemd service
This commit is contained in:
Marcin Jachymiak 2020-02-26 14:39:57 -05:00 committed by GitHub
commit 9d6748409c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 5 deletions

View File

@ -45,10 +45,23 @@ as recent as `v1.4.3`.
You still need to setup `siad` for the backend to be complete. You still need to setup `siad` for the backend to be complete.
1. `cd ~/; mkdir siad` The setup script creates a systemd user service that will run `siad` in the
2. `nohup siad &>/dev/null &` background and automatically restart upon failure. The `siad.service` file must
be placed in `~/.config/systemd/user/`
To use the `siad.service`, first fill out `~/.sia/sia.env` environment variables with the
correct values. You will need to initialize your wallet if you have not already
done so.
To enable the service: `systemctl --user enable siad.service`
### Useful Commands
To start the service: `systemctl --user start siad`
To stop it: `systemctl --user stop siad`
To check the status of it: `systemctl --user status siad`
To check standard err/standard out: `journalctl --user-unit siad`
This will start syncing `siad` in the background.
## Portal Setup ## Portal Setup

View File

@ -112,3 +112,7 @@ if ! shopt -oq posix; then
fi fi
fi fi
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/go/bin:/home/user/go/bin export PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/go/bin:/home/user/go/bin
set -o allexport
source ~/.sia/sia.env
set +o allexport

View File

@ -46,7 +46,7 @@ sudo ufw allow 'Nginx HTTP'
# Install Go 1.13.7. # Install Go 1.13.7.
wget -c https://dl.google.com/go/go1.13.7.linux-amd64.tar.gz wget -c https://dl.google.com/go/go1.13.7.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.13.7.linux-amd64.tar.gz sudo tar -C /usr/local -xzf go1.13.7.linux-amd64.tar.gz
source ~/.bashrc export PATH=$PATH:$HOME/go/bin
rm go1.13.7.linux-amd64.tar.gz rm go1.13.7.linux-amd64.tar.gz
# Sanity check that will pass if go was installed correctly. # Sanity check that will pass if go was installed correctly.
@ -57,10 +57,18 @@ cwd=$(pwd)
# Install Sia # Install Sia
cd ~/ cd ~/
git clone https://gitlab.com/NebulousLabs/Sia git clone https://gitlab.com/NebulousLabs/Sia
cd Sia && git checkout viewnode && make cd Sia && git checkout v1.4.3 && make
# Setup skynet frontend. # Setup skynet frontend.
cd $cwd cd $cwd
cd ../ cd ../
yarn yarn
yarn build yarn build
# Enable the systemd service
cd $cwd
mkdir -p ~/.config/systemd/user
cp siad.service ~/.config/systemd/user/siad.service
mkdir -p ~/.sia
cp sia.env ~/.sia/

3
setup-scripts/sia.env Normal file
View File

@ -0,0 +1,3 @@
SIA_DATA_DIR=""
SIA_API_PASSWORD=""
SIA_WALLET_PASSWORD=""

View File

@ -0,0 +1,13 @@
[Unit]
Description=siad
[Service]
Type=simple
WorkingDirectory=/home/user/siad
EnvironmentFile=/home/user/.sia/sia.env
ExecStart=/home/user/go/bin/siad
ExecStop=/home/user/go/bin/siac stop
Restart=on-failure
[Install]
WantedBy=default.target