mirror of
https://github.com/clearml/clearml-server
synced 2025-02-07 13:33:42 +00:00
68 lines
2.1 KiB
Bash
68 lines
2.1 KiB
Bash
|
#!/usr/bin/env bash
|
||
|
set -e
|
||
|
|
||
|
mkdir -p /var/log/clearml
|
||
|
|
||
|
SERVER_TYPE=$1
|
||
|
|
||
|
if (( $# < 1 )) ; then
|
||
|
echo "The server type was not stated. It should be either apiserver, webserver or fileserver."
|
||
|
sleep 60
|
||
|
exit 1
|
||
|
|
||
|
elif [[ ${SERVER_TYPE} == "apiserver" ]]; then
|
||
|
cd /opt/clearml/
|
||
|
python3 -m apiserver.apierrors_generator
|
||
|
|
||
|
if [[ -n $CLEARML_USE_GUNICORN ]]; then
|
||
|
MAX_REQUESTS=
|
||
|
if [[ -n $CLEARML_GUNICORN_MAX_REQUESTS ]]; then
|
||
|
MAX_REQUESTS="--max-requests $CLEARML_GUNICORN_MAX_REQUESTS"
|
||
|
if [[ -n $CLEARML_GUNICORN_MAX_REQUESTS_JITTER ]]; then
|
||
|
MAX_REQUESTS="$MAX_REQUESTS --max-requests-jitter $CLEARML_GUNICORN_MAX_REQUESTS_JITTER"
|
||
|
fi
|
||
|
fi
|
||
|
|
||
|
export GUNICORN_CMD_ARGS=${CLEARML_GUNICORN_CMD_ARGS}
|
||
|
|
||
|
# Note: don't be tempted to "fix" $MAX_REQUESTS with "$MAX_REQUESTS" as this produces an empty arg which fucks up gunicorn
|
||
|
gunicorn \
|
||
|
-w "${CLEARML_GUNICORN_WORKERS:-8}" \
|
||
|
-t "${CLEARML_GUNICORN_TIMEOUT:-600}" --bind="${CLEARML_GUNICORN_BIND:-0.0.0.0:8008}" \
|
||
|
$MAX_REQUESTS apiserver.server:app
|
||
|
else
|
||
|
python3 -m apiserver.server
|
||
|
fi
|
||
|
|
||
|
elif [[ ${SERVER_TYPE} == "webserver" ]]; then
|
||
|
|
||
|
if [[ "${USER_KEY}" != "" ]] || [[ "${USER_SECRET}" != "" ]] || [[ "${COMPANY_ID}" != "" ]]; then
|
||
|
cat << EOF > /usr/share/nginx/html/credentials.json
|
||
|
{
|
||
|
"userKey": "${USER_KEY}",
|
||
|
"userSecret": "${USER_SECRET}",
|
||
|
"companyID": "${COMPANY_ID}"
|
||
|
}
|
||
|
EOF
|
||
|
fi
|
||
|
|
||
|
export NGINX_APISERVER_ADDR=${NGINX_APISERVER_ADDRESS:-http://apiserver:8008}
|
||
|
export NGINX_FILESERVER_ADDR=${NGINX_FILESERVER_ADDRESS:-http://fileserver:8081}
|
||
|
|
||
|
envsubst '${NGINX_APISERVER_ADDR} ${NGINX_FILESERVER_ADDR}' < /etc/nginx/clearml.conf.template > /etc/nginx/nginx.conf
|
||
|
|
||
|
#start the server
|
||
|
/usr/sbin/nginx -g "daemon off;"
|
||
|
|
||
|
elif [[ ${SERVER_TYPE} == "fileserver" ]]; then
|
||
|
cd /opt/clearml/fileserver/
|
||
|
if [ "$FILESERVER_USE_GUNICORN" = true ] ; then
|
||
|
gunicorn -t 600 --bind=0.0.0.0:8081 fileserver:app
|
||
|
else
|
||
|
python3 fileserver.py
|
||
|
fi
|
||
|
|
||
|
else
|
||
|
echo "Server type ${SERVER_TYPE} is invalid. Please choose either apiserver, webserver or fileserver."
|
||
|
fi
|