mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-18 00:00:00 +00:00
seafile monitor check_python_executable (#5940)
This commit is contained in:
@@ -24,6 +24,37 @@ export PYTHONPATH=$PYTHONPATH:$pro_pylibs_dir
|
||||
export SEAFES_DIR=$seafesdir
|
||||
export SEAHUB_DIR=$seahubdir
|
||||
|
||||
function check_python_executable() {
|
||||
if [[ "$PYTHON" != "" && -x $PYTHON ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if which python3 2>/dev/null 1>&2; then
|
||||
PYTHON=python3
|
||||
elif !(python --version 2>&1 | grep "3\.[0-9]\+\.[0-9]\+") 2>/dev/null 1>&2; then
|
||||
echo
|
||||
echo "The current version of python is not 3.x.x, please use Python 3.x.x ."
|
||||
echo
|
||||
exit 1
|
||||
else
|
||||
# Python 3.8.10
|
||||
PYTHON="python"$(python --version | cut -b 8-10)
|
||||
|
||||
if !(which $PYTHON) 2>/dev/null 1>&2; then
|
||||
# Python 3.10.4
|
||||
PYTHON="python"$(python --version | cut -b 8-11)
|
||||
fi
|
||||
if !(which $PYTHON) 2>/dev/null 1>&2; then
|
||||
echo
|
||||
echo "Can't find a python executable of $PYTHON in PATH"
|
||||
echo "Install $PYTHON before continue."
|
||||
echo "Or if you installed it in a non-standard PATH, set the PYTHON enviroment variable to it"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# log function
|
||||
function log() {
|
||||
local time=$(date +"%F %T")
|
||||
@@ -49,7 +80,8 @@ function start_notification_server() {
|
||||
}
|
||||
|
||||
function start_seafevents() {
|
||||
/usr/bin/python3 -m seafevents.main --config-file ${central_config_dir}/seafevents.conf --logfile ${TOPDIR}/logs/seafevents.log -P ${TOPDIR}/pids/seafevents.pid &
|
||||
check_python_executable;
|
||||
$PYTHON -m seafevents.main --config-file ${central_config_dir}/seafevents.conf --logfile ${TOPDIR}/logs/seafevents.log -P ${TOPDIR}/pids/seafevents.pid &
|
||||
sleep 1
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user