1 简介
pip install climateserv
conda install -c servir climateserv
Python 3.9.5 或更高版本 (建议使用 3.9.5)
PostgreSQL (版本 13)
THREDDS (版本 4.6.14)
Linux 服务器
2 在conda 环境中设置数据库
mkdir -p /cserv2/python_environments/conda/anaconda3/envs/
conda create --prefix=/cserv2/python_environments/conda/anaconda3/envs/psqlenv python=3.9.5
conda create --name psqlenv python=3.9.5
conda activate psqlenv
conda install -y -c conda-forge postgresql
cd /cserv2
mkdir db
cd db
initdb -D local_climateserv
pg_ctl -D local_climateserv -l logfile start
createuser --encrypted --pwprompt csadmin
createdb --owner=csadmin cs2_db
conda deactivate
{
"NAME": "cs2_db",
"USER": "csadmin",
"PASSWORD": "PASSWORD_YOU_SET_FOR_THIS_USER",
"HOST": "127.0.0.1",
"SECRET_KEY": "Your_super_secret_key_for_django"
"DEBUG": "False"
}
3 在conda 环境中设置应用程序
conda create --prefix=/cserv2/python_environments/conda/anaconda3/envs/climateserv2 python=3.9.5
conda activate ClimateSERV2
pip install -r requirements.txt
conda install --file conda_requirements.txt
sudo apt-get install rabbitmq-server
sudo systemctl enable rabbitmq-server
sudo service rabbitmq-server start
[Unit]
Description=Celery Service
After=rabbitmq-server.service network.target
Requires=rabbitmq-server.service
RuntimeDirectory=celery
[Service]
Type=forking
User=www-data
Group=www-data
EnvironmentFile=/etc/conf.d/celery
WorkingDirectory=/cserv2/django_app/ClimateSERV2
ExecStart=/bin/bash -c '${CELERY_BIN} -A $CELERY_APP multi start $CELERYD_NODES \
--pidfile=${CELERYD_PID_FILE} --logfile=${CELERYD_LOG_FILE} \
--loglevel="${CELERYD_LOG_LEVEL}" $CELERYD_OPTS'
ExecStop=/bin/sh -c '${CELERY_BIN} multi stopwait $CELERYD_NODES \
--pidfile=${CELERYD_PID_FILE} --logfile=${CELERYD_LOG_FILE} \
--loglevel="${CELERYD_LOG_LEVEL}"'
ExecReload=/bin/sh -c '${CELERY_BIN} -A $CELERY_APP multi restart $CELERYD_NODES \
--pidfile=${CELERYD_PID_FILE} --logfile=${CELERYD_LOG_FILE} \
--loglevel="${CELERYD_LOG_LEVEL}" $CELERYD_OPTS'
Restart=always
[Install]
WantedBy=multi-user.target
CELERYD_NODES="w1 w2 w3"
DJANGO_SETTINGS_MODULE="climateserv2.settings"
# Absolute or relative path to the 'celery' command:
CELERY_BIN="/cserv2/python_environments/conda/anaconda3/envs/climateserv2/bin/celery"
# App instance to use
CELERY_APP="climateserv2"
CELERYD_MULTI="multi"
# Extra command-line arguments to the worker
CELERYD_OPTS="--time-limit=300 --concurrency=8"
CELERYD_PID_FILE="/var/run/celery/%n.pid"
CELERYD_LOG_FILE="/var/log/celery/%n%I.log"
D /var/run/celery 0777 root root - -
sudo mkdir /var/run/celery
sudo chmod 777 /var/run/celery -R
sudo mkdir /opt/celery
sudo chmod 777 /opt/celery
sudo mkdir /var/log/celery
sudo chmod 777 /var/log/celery -R
sudo chmod 644 /etc/systemd/system/celery.service
sudo systemctl daemon-reload
sudo systemctl enable celery
sudo service celery restart
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver