mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-06-24 14:11:34 +00:00
add conf/gunicorn.conf
This commit is contained in:
parent
a9d7992396
commit
df546983ce
@ -19,13 +19,12 @@ default_ccnet_conf_dir=${TOPDIR}/ccnet
|
||||
central_config_dir=${TOPDIR}/conf
|
||||
|
||||
manage_py=${INSTALLPATH}/seahub/manage.py
|
||||
gunicorn_conf=${INSTALLPATH}/runtime/seahub.conf
|
||||
pidfile=${INSTALLPATH}/runtime/seahub.pid
|
||||
errorlog=${INSTALLPATH}/runtime/error.log
|
||||
accesslog=${INSTALLPATH}/runtime/access.log
|
||||
gunicorn_conf=${TOPDIR}/conf/gunicorn.conf
|
||||
pidfile=${TOPDIR}/pids/seahub.pid
|
||||
errorlog=${TOPDIR}/logs/gunicorn_error.log
|
||||
accesslog=${TOPDIR}/logs/gunicorn_access.log
|
||||
gunicorn_exe=${INSTALLPATH}/seahub/thirdpart/gunicorn
|
||||
|
||||
|
||||
script_name=$0
|
||||
function usage () {
|
||||
echo "Usage: "
|
||||
@ -158,7 +157,7 @@ function start_seahub () {
|
||||
before_start;
|
||||
echo "Starting seahub at port ${port} ..."
|
||||
check_init_admin;
|
||||
$PYTHON $gunicorn_exe seahub.wsgi:application -c "${gunicorn_conf}" -b "0.0.0.0:${port}" --preload
|
||||
$PYTHON $gunicorn_exe seahub.wsgi:application -c "${gunicorn_conf}" --preload
|
||||
|
||||
# Ensure seahub is started successfully
|
||||
sleep 5
|
||||
|
@ -303,6 +303,8 @@ class EnvManager(object):
|
||||
self.top_dir = os.path.dirname(self.install_path)
|
||||
self.bin_dir = os.path.join(self.install_path, 'seafile', 'bin')
|
||||
self.central_config_dir = os.path.join(self.top_dir, 'conf')
|
||||
self.central_pids_dir = os.path.join(self.top_dir, 'pids')
|
||||
self.central_logs_dir = os.path.join(self.top_dir, 'logs')
|
||||
Utils.must_mkdir(self.central_config_dir)
|
||||
|
||||
def check_pre_condiction(self):
|
||||
@ -1165,6 +1167,44 @@ share_name = /
|
||||
with open(self.seafdav_conf, 'w') as fp:
|
||||
fp.write(text)
|
||||
|
||||
class GunicornConfigurator(AbstractConfigurator):
|
||||
def __init__(self):
|
||||
AbstractConfigurator.__init__(self)
|
||||
self.gunicorn_conf = None
|
||||
|
||||
def ask_questions(self):
|
||||
pass
|
||||
|
||||
def generate(self):
|
||||
self.gunicorn_conf = os.path.join(env_mgr.central_config_dir, 'gunicorn.conf')
|
||||
template = '''
|
||||
import os
|
||||
|
||||
daemon = True
|
||||
workers = 5
|
||||
|
||||
# default localhost:8000
|
||||
bind = "0.0.0.0:8000"
|
||||
|
||||
# Pid
|
||||
pids_dir = '%(pids_dir)s'
|
||||
pidfile = os.path.join(pids_dir, 'seahub.pid')
|
||||
|
||||
# Logging
|
||||
logs_dir = '%(logs_dir)s'
|
||||
errorlog = os.path.join(logs_dir, 'gunicorn_error.log')
|
||||
accesslog = os.path.join(logs_dir, 'gunicorn_access.log')
|
||||
|
||||
# for file upload, we need a longer timeout value (default is only 30s, too short)
|
||||
timeout = 1200
|
||||
'''
|
||||
|
||||
text = template % dict(pids_dir=env_mgr.central_pids_dir,
|
||||
logs_dir=env_mgr.central_logs_dir)
|
||||
|
||||
with open(self.gunicorn_conf, 'w') as fp:
|
||||
fp.write(text)
|
||||
|
||||
class UserManualHandler(object):
|
||||
def __init__(self):
|
||||
self.src_docs_dir = os.path.join(env_mgr.install_path, 'seafile', 'docs')
|
||||
@ -1260,6 +1300,7 @@ env_mgr = EnvManager()
|
||||
ccnet_config = CcnetConfigurator()
|
||||
seafile_config = SeafileConfigurator()
|
||||
seafdav_config = SeafDavConfigurator()
|
||||
gunicorn_config = GunicornConfigurator()
|
||||
seahub_config = SeahubConfigurator()
|
||||
user_manuals_handler = UserManualHandler()
|
||||
# Would be created after AbstractDBConfigurator.ask_use_existing_db()
|
||||
@ -1424,6 +1465,7 @@ def main():
|
||||
ccnet_config.generate()
|
||||
seafile_config.generate()
|
||||
seafdav_config.generate()
|
||||
gunicorn_config.generate()
|
||||
seahub_config.generate()
|
||||
|
||||
seahub_config.do_syncdb()
|
||||
|
@ -7,6 +7,8 @@ default_ccnet_conf_dir=${TOPDIR}/ccnet
|
||||
default_seafile_data_dir=${TOPDIR}/seafile-data
|
||||
default_seahub_db=${TOPDIR}/seahub.db
|
||||
default_conf_dir=${TOPDIR}/conf
|
||||
default_pids_dir=${TOPDIR}/pids
|
||||
default_logs_dir=${TOPDIR}/logs
|
||||
|
||||
export SEAFILE_LD_LIBRARY_PATH=${INSTALLPATH}/seafile/lib/:${INSTALLPATH}/seafile/lib64:${LD_LIBRARY_PATH}
|
||||
|
||||
@ -300,6 +302,36 @@ function get_seafile_data_dir () {
|
||||
echo
|
||||
}
|
||||
|
||||
function gen_gunicorn_conf () {
|
||||
mkdir -p ${default_conf_dir}
|
||||
gunicorn_conf=${default_conf_dir}/gunicorn.conf
|
||||
if ! $(cat > ${gunicorn_conf} <<EOF
|
||||
import os
|
||||
|
||||
daemon = True
|
||||
workers = 5
|
||||
|
||||
# default localhost:8000
|
||||
bind = "0.0.0.0:8000"
|
||||
|
||||
# Pid
|
||||
pids_dir = '$default_pids_dir'
|
||||
pidfile = os.path.join(pids_dir, 'seahub.pid')
|
||||
|
||||
# Logging
|
||||
logs_dir = '$default_logs_dir'
|
||||
errorlog = os.path.join(logs_dir, 'gunicorn_error.log')
|
||||
accesslog = os.path.join(logs_dir, 'gunicorn_access.log')
|
||||
|
||||
# for file upload, we need a longer timeout value (default is only 30s, too short)
|
||||
timeout = 1200
|
||||
EOF
|
||||
); then
|
||||
echo "failed to generate gunicorn.conf";
|
||||
err_and_quit
|
||||
fi
|
||||
}
|
||||
|
||||
function gen_seafdav_conf () {
|
||||
mkdir -p ${default_conf_dir}
|
||||
seafdav_conf=${default_conf_dir}/seafdav.conf
|
||||
@ -517,6 +549,12 @@ fi
|
||||
|
||||
echo "${seafile_data_dir}" > "${default_ccnet_conf_dir}/seafile.ini"
|
||||
|
||||
# -------------------------------------------
|
||||
# Generate gunicorn.conf
|
||||
# -------------------------------------------
|
||||
|
||||
gen_gunicorn_conf;
|
||||
|
||||
# -------------------------------------------
|
||||
# Generate seafevents.conf
|
||||
# -------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user