Skip to content

Commit

Permalink
Create systemd service when the release is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel authored and Samuel committed Sep 15, 2021
1 parent c9ea3e9 commit 033991c
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
set -e
trap 'echo "******* FAILED *******" 1>&2' ERR

INSTALL_DIR=~/aebot/build
USER=$(whoami)
INSTALL_DIR=/home/$USER/aebot/build
UPGRADE=0

usage() {
Expand Down Expand Up @@ -71,14 +72,54 @@ then
echo "Run the upgrade"
$INSTALL_DIR/bin/archethic_node upgrade ${VERSION}
else
# Build the releases
# Build and install the releases

echo "Generate release"
MIX_ENV=prod mix distillery.release

echo "Install release"
tar zxvf _build/prod/rel/archethic_node/releases/$VERSION/archethic_node.tar.gz -C $INSTALL_DIR
echo "Release has been installed on ${INSTALL_DIR}"

echo "Creating service file"
sudo bash -c 'cat > /etc/systemd/system/archethic.service' << EOF
[Unit]
Description=ARCHEthic service
After=local-fs.target network.target
[Service]
Type=simple
User=$USER
Group=$USER
WorkingDirectory=$INSTALL_DIR
ExecStart=$INSTALL_DIR/bin/archethic_node foreground
ExecStop=$INSTALL_DIR/bin/archethic_node stop
EnvironmentFile=/etc/default/archethic.env
Environment=LANG=en_US.utf8
Environment=MIX_ENV=prod
Restart=on-failure
RemainAfterExit=yes
RestartSec=5
LimitNOFILE=65535
UMask=0027
SyslogIdentifier=archethic
[Install]
WantedBy=multi-user.target
EOF

# restart daemon, enable and start service
echo "Reloading daemon and enabling service"
sudo systemctl daemon-reload
sudo systemctl enable archethic
sudo systemctl start archethic
echo "Service Started"
fi

exit

0 comments on commit 033991c

Please sign in to comment.