Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable systemd service #80

Merged
2 commits merged into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ config :archethic, ArchEthic.BeaconChain.SummaryTimer,

config :archethic, ArchEthic.Crypto,
root_ca_public_keys: [
tpm: System.get_env("ARCHETHIC_CRYPTO_ROOT_CA_TPM_PUBKEY", "") |> Base.decode16!(case: :mixed)
tpm:
System.get_env(
"ARCHETHIC_CRYPTO_ROOT_CA_TPM_PUBKEY",
"3059301306072a8648ce3d020106082a8648ce3d03010703420004f0fe701a03ce375a6e57adbe0255808812036571c1424db2779c77e8b4a9ba80a15b118e8e7465ee2e94094e59c4b3f7177e99063af1b19bfcc4d7e1ac3f89dd"
)
|> Base.decode16!(case: :mixed)
],
key_certificates_dir: System.get_env("ARCHETHIC_CRYPTO_CERT_DIR", "~/aebot/key_certificates")

Expand Down
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