Skip to content

Commit

Permalink
#227 add systemd service file
Browse files Browse the repository at this point in the history
  • Loading branch information
elKei24 committed Feb 4, 2021
1 parent d040302 commit fb6a28f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
path: ~/project
- attach_workspace:
at: /tmp/workspace
- run: ../scripts/backend_deb.sh -v 0.1 -t /tmp/workspace/build/distributions/*.tar
- run: ../scripts/backend_deb.sh -v 0.1 -t /tmp/workspace/build/distributions/*.tar -s ../scripts/eak-backend.service
- run: |
mkdir -p /tmp/artifacts
cp *.deb /tmp/artifacts
Expand Down
24 changes: 14 additions & 10 deletions scripts/backend_deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,21 @@ maintainer="The Ehrenamtskarte Team <[email protected]>"
description="Backend server for the Ehrenamtskarte app"

# read input
while getopts v:r:a:n:t:h flag
while getopts v:r:a:n:t:s:h flag
do
case "${flag}" in
v) version=${OPTARG};;
r) revision=${OPTARG};;
a) architecture=${OPTARG};;
n) name=${OPTARG};;
t) tarfile=${OPTARG};;
s) servicefile=${OPTARG};;
h)
echo "$0 [-v version] [-r revision] [-a architecture] [-n name] -t backend_tar"
echo "$0 [-v version] [-r revision] [-a architecture] [-n name] [-t backend_tar] [-s service_file]"
exit 0;;
esac
done

if [[ -z "$tarfile" ]]; then
echo "Must provide input tar file using -t file" 1>&2
exit 1
fi

debworkdir=$(mktemp -d)
fullname=${name}_${version}-${revision}_${architecture}
debfile=${fullname}.deb
Expand All @@ -45,9 +41,17 @@ echo "Maintainer: $maintainer" >> $ctrlfile
echo "Description: $description" >> $ctrlfile

# copy files to deb workdir
echo "Copying $tarfile"
mkdir -p ${debworkdir}/var/ehrenamtskarte/backend
tar -xf $tarfile -C ${debworkdir}/var/ehrenamtskarte
if [[ -n "$tarfile" ]]; then
echo "Copying $tarfile"
mkdir -p ${debworkdir}/opt/ehrenamtskarte/backend
tar -xf $tarfile -C ${debworkdir}/opt/ehrenamtskarte
fi
if [[ -n "$servicefile" ]]; then
echo "Copying $servicefile"
mkdir -p ${debworkdir}/etc/systemd/system
cp $servicefile ${debworkdir}/etc/systemd/system/${name}.service
fi


# build the deb
dpkg-deb --build --root-owner-group $debworkdir $debfile
Expand Down
13 changes: 13 additions & 0 deletions scripts/eak-backend.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Backend for the ehrenamtskarte app
After=postgresql.service network-online.target
Wants=network-online.target systemd-networkd-wait-online.service

StartLimitIntervalSec=500
StartLimitBurst=5

[Service]
Type=simple
ExecStart=/opt/ehrenamtskarte/backend/bin/backend
Restart=on-failure
RestartSec=5s

0 comments on commit fb6a28f

Please sign in to comment.