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

Doltab needs a systemd file #56

Open
bitfactory-sem-denbroeder opened this issue Feb 15, 2023 · 1 comment
Open

Doltab needs a systemd file #56

bitfactory-sem-denbroeder opened this issue Feb 15, 2023 · 1 comment

Comments

@bitfactory-sem-denbroeder
Copy link

bitfactory-sem-denbroeder commented Feb 15, 2023

doltab currently doesnt have a systemd/unit file in order to consistently run the server in case of a reboot. i've created a sample service.sh which would allow for this file to be created and start the doltlab containers via systemd.

#!/bin/bash

set -e

# script should run as root
if [ "$EUID" -ne 0 ]
  then echo "Please run as root"
  exit
fi

# get current dir and append start-doltlab.sh to it
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SCRIPT="$DIR/start-doltlab.sh"

# create service file with script as ExecStart
unit="[Unit]
Description=%i DoltLab server
PartOf=docker.service
After=docker.service

[Service]
Type=oneshot
User=root
RemainAfterExit=true
WorkingDirectory=$DIR
ExecStart=$SCRIPT
ExecStop=/usr/local/bin/docker-compose down

[Install]
WantedBy=multi-user.target"
# test if unit is the same as the one present
if [ "$unit" = "$(cat /etc/systemd/system/doltlab.service)" ]; then
    echo "Service already exists at /etc/systemd/system/doltlab.service"
    exit 0
else
    echo "Creating service at /etc/systemd/system/doltlab.service"
    echo "$unit" > /etc/systemd/system/doltlab.service
fi
# reload deamon
systemctl daemon-reload
# enable service
systemctl enable doltlab.service
# start service
systemctl start doltlab.service
@bitfactory-sem-denbroeder
Copy link
Author

This issue depends on #55 as systemd needs the env vars to start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant