Merge feature--infinite-seafile-restart-into-healthchecks into staging

This commit is contained in:
flow.gunso
2019-04-25 16:42:23 +02:00
14 changed files with 122 additions and 38 deletions

View File

@@ -39,7 +39,7 @@ if [ "$GID" != "1000" ]; then
fi
# Set the files ownership.
chown $UID.$GID -R /home/seafuser/infinite-seaf-cli-start.sh
chown $UID.$GID -R /home/seafuser/seafile-healthcheck.sh
chown $UID.$GID -R /home/seafuser/entrypoint.sh
chown $UID.$GID -R /volume

View File

@@ -39,7 +39,7 @@ if [ "$GID" != "1000" ]; then
fi
# Set the files ownership.
chown $UID.$GID /home/seafuser/infinite-seaf-cli-start.sh
chown $UID.$GID /home/seafuser/seafile-healthcheck.sh
chown $UID.$GID /home/seafuser/entrypoint.sh
chown $UID.$GID -R /volume

View File

@@ -25,7 +25,7 @@ if [ -z $SEAF_LIBRARY_UUID ]; then echo "The \$SEAF_LIBRARY_UUID was not defined
# Update the user ID, if the $UID changed.
if [ "$UID" != "1000" ]; then
usermod -u $UID $UNAME
# What if the $UID already exists ?
# TODO: What if the $UID already exists ?
fi
# Change the group, if the $GID changed.
@@ -40,7 +40,7 @@ fi
# Set the files ownership.
chown $UID.$GID -R /home/seafuser/supervisord.conf
chown $UID.$GID -R /home/seafuser/infinite-seaf-cli-start.sh
chown $UID.$GID -R /home/seafuser/seafile-healthcheck.sh
chown $UID.$GID -R /home/seafuser/entrypoint.sh
chown $UID.$GID -R /volume

View File

@@ -1,24 +0,0 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
/bin/sleep 10
while true; do
/usr/bin/seaf-cli stop
/usr/bin/seaf-cli start
/bin/sleep 1200
done

View File

@@ -35,4 +35,4 @@ while [ ! -S $seafile_sock ]; do sleep 1; done
/usr/bin/seaf-cli sync -u $SEAF_USERNAME -p $SEAF_PASSWORD -s $SEAF_SERVER_URL -l $SEAF_LIBRARY_UUID -d /volume
# Run the infinite Seafile restart.
source ~/infinite-seaf-cli-start.sh
source ~/seafile-healthcheck.sh

View File

@@ -22,7 +22,6 @@ seafile_sock=~/.seafile/seafile-data/seafile.sock
# Prepare the directories.
mkdir ~/.seafile
mkdir ~/.supervisord
# Safely initialise the Seafile client.
/usr/bin/seaf-cli init -d ~/.seafile

View File

@@ -0,0 +1,42 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# `seaf-cli status` output csv-like information with tabulates as separators and columns named in comment lines.
# The Seafile client should not be restarted while some statuses are occuring, such as "downloading" or "committing".
#
# This script grabs the output while ignoring the comments to iterate over the informations set to their columns,
# then it compares the statuses, when not empty, to the ones that do not require a restart. Finally either restart or don't.
seaf=/usr/bin/seaf-cli
dont_restart_on=("downloading" "committing" "waiting for sync")
restart=true
while IFS=$'\t' read -r name status progress; do
if [ $status ]; then
for dont_restart_on_status in "${dont_restart_on[@]}"; do
if [ "$status" == "$dont_restart_on_status" ]; then
restart=false; break; break
fi
done
fi
done < <($seaf status | grep -v "^#")
if $restart; then
$seaf stop
$seaf start
fi

47
assets/seafile-healthcheck.sh Executable file
View File

@@ -0,0 +1,47 @@
#!/bin/bash
# Docker Seafile client, help you mount a Seafile library as a volume.
# Copyright (C) 2019, flow.gunso@gmail.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# `seaf-cli status` output csv-like information with tabulates as separators and columns named in comment lines.
# The Seafile client should not be restarted while some statuses are occuring, such as "downloading" or "committing".
#
# This script grabs the output while ignoring the comments to iterate over the informations set to their columns,
# then it compares the statuses, when not empty, to the ones that do not require a restart. Finally either restart or don't.
seaf=/usr/bin/seaf-cli
dont_restart_on=("downloading" "committing" "waiting for sync")
restart=true
sleep 10s
while true; do
while IFS=$'\t' read -r name status progress; do
if [ $status ]; then
for dont_restart_on_status in "${dont_restart_on[@]}"; do
if [ "$status" == "$dont_restart_on_status" ]; then
restart=false; break; break
fi
done
fi
done < <($seaf status | grep -v "^#")
if $restart; then
$seaf stop
$seaf start
fi
sleep 10m
done

View File

@@ -24,7 +24,7 @@ file=~/.seafile/seafile-data/seafile.sock
# Manage the infinite `seaf-cli start`.
[program:seaf-cli-start-loop]
command=/bin/bash /home/seafuser/infinite-seaf-cli-start.sh
command=/bin/bash /home/seafuser/seafile-healthcheck.sh
process_name=%(program_name)s
numprocs=1
autostart=true