pad.libre-service.eu-etherpad/bin/safeRun.sh
JannikStreek 04063d664b
cleanup after workspace refactoring (#6174)
* fix bin folder and workflows as far its possible

cleanup of dockerfile

changed paths of scripts

add lock file

fix working directory for workflows

fix windows bin

fix travis (is travis used anyway?)

fix package refs

remove pnpm-lock file in root as these conflicts with the docker volume setup

optimize comments

use install again

refactor prod image call to run

fix --workspace can only be used inside a workspace

correct comment

try fix pipeline

try fix pipeline for upgrade-from-latest-release

install all deps

smaller adjustments

save

update dockerfile

remove workspace command

fix run test command

start repair latest release workflow

start repair latest release workflow

start repair latest release workflow

further repairs

* remove test plugin from docker compose
2024-02-21 21:50:11 +01:00

70 lines
1.7 KiB
Bash
Executable file

#!/bin/sh
# This script ensures that ep-lite is automatically restarting after
# an error happens
# Handling Errors
# 0 silent
# 1 email
ERROR_HANDLING=0
# Your email address which should receive the error messages
EMAIL_ADDRESS="no-reply@example.com"
# Sets the minimum amount of time between the sending of error emails.
# This ensures you do not get spammed during an endless reboot loop
# It's the time in seconds
TIME_BETWEEN_EMAILS=600 # 10 minutes
# DON'T EDIT AFTER THIS LINE
pecho() { printf %s\\n "$*"; }
log() { pecho "$@"; }
error() { log "ERROR: $@" >&2; }
fatal() { error "$@"; exit 1; }
LAST_EMAIL_SEND=0
# Move to the Etherpad base directory.
MY_DIR=$(cd "${0%/*}" && pwd -P) || exit 1
cd "${MY_DIR}/.." || exit 1
# Check if a logfile parameter is set
LOG="$1"
[ -n "${LOG}" ] || fatal "Set a logfile as the first parameter"
shift
while true; do
# Try to touch the file if it doesn't exist
[ -f "${LOG}" ] || touch "${LOG}" || fatal "Logfile '${LOG}' is not writeable"
# Check if the file is writeable
[ -w "${LOG}" ] || fatal "Logfile '${LOG}' is not writeable"
# Start the application
bin/run.sh "$@" >>${LOG} 2>>${LOG}
TIME_FMT=$(date +%Y-%m-%dT%H:%M:%S%z)
# Send email
if [ "$ERROR_HANDLING" = 1 ]; then
TIME_NOW=$(date +%s)
TIME_SINCE_LAST_SEND=$(($TIME_NOW - $LAST_EMAIL_SEND))
if [ "$TIME_SINCE_LAST_SEND" -gt "$TIME_BETWEEN_EMAILS" ]; then
{
cat <<EOF
Server was restarted at: ${TIME_FMT}
The last 50 lines of the log before the server exited:
EOF
tail -n 50 "${LOG}"
} | mail -s "Etherpad restarted" "$EMAIL_ADDRESS"
LAST_EMAIL_SEND=$TIME_NOW
fi
fi
pecho "RESTART! ${TIME_FMT}" >>${LOG}
# Sleep 10 seconds before restart
sleep 10
done