Warning |
---|
Ensure python3.6 and git25 are selected in this environment. The default python is 2.7 and the default git 1.7 neither of these are new enough to use for this project. Newer versions from the software collection have been installed and can be enabled by:
|
Nephwork (Browse Miscellaneous / nephwork.renalreg.org - Bitbucket (ukrdc.org)) is deployed on the renalreg server on the url https://nephwork.renalreg.org. (it is also configured for https://nephwork.renal.org )
...
The site code is located in /home/nephwork/nephwork.renalreg.org
and is run on port 9887.
The standard construct used for configuring the required Django settings is used where by there is a settings folder containing settings files for different environments. There is a base settings file and then individualised settings files for the different environments (local and production in this case). The selection of the correct settings file is done by using the DJANGO_SETTINGS_MODULE
environment variable.
When running the site ensure the environment variable is appropriately set:
Code Block | ||
---|---|---|
| ||
# Settings files ls -l nephwork/settings total 20 -rw-r--r--. 1 nephwork nephwork 3975 Nov 25 16:32 base.py -rw-r--r--. 1 nephwork nephwork 29 Nov 25 16:32 __init__.py -rw-r--r--. 1 nephwork nephwork 429 Nov 25 16:32 local.py -rw-r--r--. 1 nephwork nephwork 1213 Nov 25 16:32 production.py # Configure productions settings export DJANGO_SETTINGS_MODULE=nephwork.settings.production |
Note |
---|
Note the environment needs setting before running the start script to ensure the correct settings file is picked up export DJANGO_SETTINGS_MODULE=nephwork.settings.production; To export DJANGO_SETTINGS_MODULE value permanently in every nephwork user session, add the line export DJANGO_SETTINGS_MODULE=nephwork.settings.production in ~/.bash_profile. To load the new variable in the current session run: $ source ~/.bash_profile |
The site is managed using a script in /home/nephwork/bin/nephwork
which takes commands start, stop, force-reload/restart
Code Block | ||||
---|---|---|---|---|
| ||||
#! /bin/bash
### BEGIN INIT INFO
# Provides: nephwork
# Required-Start: nginx/apache
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: The main django process
# Description: The gunicorn process that receives HTTP requests
# from nginx/apache
#
### END INIT INFO
#
# Author: Tim Whitlock <tim.whitlock@renalregistry.nhs.uk>
#
# Replace this with absolute path to project directory if used as init.d script
#PROJDIR="$(dirname `dirname "${BASH_SOURCE[0]}"`)";
PROJDIR="/home/nephwork/nephwork.renalreg.org";
APPNAME=nephwork
USER=nephwork
PATH=/bin:/usr/bin:/sbin:/usr/sbin
ACTIVATE=$PROJDIR/venv/bin/activate
APPMODULE=nephwork.wsgi
DAEMON=gunicorn
BIND=127.0.0.1:9887
# Put under /var/run and /var/log to make more consistent with other init.d scripts
# Subdriectories in /var/run and /var/log need to be owned by this user for logging and pid to be saved.
#PIDFILE=$PROJDIR/$DAEMON-nephwork.pid
PIDFILE=/var/run/nephwork/$DAEMON-nephwork.pid
#LOGFILE=$PROJDIR/logs/$DAEMON-nephwork.log
LOGFILE=/var/log/nephwork/$DAEMON-nephwork.log
WORKERS=2
#if [ ! -d "$PROJDIR/logs" ]; then
# mkdir -p "$PROJDIR/logs";
#fi
if [ ! -d "/var/log/nephwork" ]; then
mkdir -p "/var/log/nephwork";
fi
. /lib/lsb/init-functions
if [ -e "/etc/default/$APPNAME" ]
then
. /etc/default/$APPNAME
fi
case "$1" in
start)
# log_daemon_msg "Starting deferred execution scheduler" "$APPNAME"
source $ACTIVATE
$DAEMON --daemon --bind=$BIND --pid=$PIDFILE --workers=$WORKERS --user=$USER --log-file=$LOGFILE $APPMODULE
RETVAL=$?
if [ $RETVAL = 0 ]; then
log_success_msg "$APPNAME has started";
else
log_failure_msg "Failed to start $APPNAME";
fi
;;
stop)
# log_daemon_msg "Stopping deferred execution scheduler" "$APPNAME"
killproc -p $PIDFILE $DAEMON
RETVAL=$?
if [ $RETVAL = 0 ]; then
log_success_msg "$APPNAME has stopped";
else
log_failure_msg "Failed to stop $APPNAME";
fi
;;
force-reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: ./bin/$APPNAME {start|stop|restart|force-reload}"
exit 1
;;
esac
exit 0
|
The log files can be found in /var/log/httpd24
for proxy issues and /var/log/nephwork
for django site related issues.