-
-
Save dkackman/517739d1affc9403c2bc8ce4c1125917 to your computer and use it in GitHub Desktop.
chia systemd service unit defintion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# if no parameters are supplied this results in: | |
# . ~/chia-blochain/activate | |
# chia start farmer | |
# | |
if [ -z "$1" ] | |
then | |
operation=start | |
else | |
operation=$1 | |
fi | |
if [ -z "$2" ] | |
then | |
chia_location=~/chia-blockchain | |
else | |
chia_location=$2 | |
fi | |
if [ -z "$3" ] | |
then | |
services=farmer | |
else | |
services=$3 | |
fi | |
if [ ! -d "$chia_location" ] | |
then | |
echo "chia not found: $chia_location" | |
exit 1 | |
fi | |
# enter the venv | |
. $chia_location/activate | |
# start/stop/reload services | |
if [ "$operation" == "start" ] | |
then | |
chia start $services | |
elif [ "$operation" == "stop" ] | |
then | |
chia stop all -d | |
elif [ "$operation" == "reload" ] | |
then | |
chia start $services -r | |
else | |
echo "Unrecognized operation $operation" | |
exit 1 | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Chia services | |
Requires=network.target | |
After=network.target | |
[Service] | |
Type=forking | |
ExecStart=/usr/local/bin/chia start /home/USERNAME/chia-blockchain farmer | |
ExecStop=/usr/local/bin/chia stop /home/USERNAME/chia-blockchain | |
ExecReload=/usr/local/bin/chia reload /home/USERNAME/chia-blockchain farmer | |
User=USERNAME | |
[Install] | |
WantedBy=multi-user.target |
On my Raspberry Pi I installed Chia using the ARM deb package, and, In order to autostart services in Raspberry PI, I've to do this:
create the service:
$ cd /etc/systemd/system && sudo nano chia.service
Past the following code:
[Unit]
Description=Chia Services
Requires=network.target
After=network.target
[Service]
Type=forking
ExecStart=/lib/chia-blockchain/resources/app.asar.unpacked/daemon/chia start farmer
ExecStop=/lib/chia-blockchain/resources/app.asar.unpacked/daemon/chia stop
ExecReload=/lib/chia-blockchain/resources/app.asar.unpacked/daemon/chia reload farmer
User=pi
[Install]
WantedBy=multi-user.target
Then, Must execute the mentioned systemctl commands.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in order to auto start some chia services
chia
in/usr/local/bin
chmod +x chia
chia.service
file (passed directly to chia start)chia.service
file with the actual user namesudo cp chia.service /etc/systemd/system
sudo systemctl start chia
sudo systemctl status chia
sudo systemctl enable chia
to set to autorun