2017-10-23 02:47:26 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
BASE=/app
|
|
|
|
|
|
|
|
if [ ! -f "$BASE/custom_settings.py" ]; then
|
|
|
|
echo SECRET_KEY=\"$(cat /dev/urandom | head -1 | md5sum | head -c 32)\" >> /app/oj/custom_settings.py
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d "$BASE/log" ]; then
|
|
|
|
mkdir -p $BASE/log
|
|
|
|
fi
|
|
|
|
|
|
|
|
cd $BASE
|
|
|
|
find . -name "*.pyc" -delete
|
|
|
|
|
2017-10-23 12:59:44 +00:00
|
|
|
# wait for postgresql start
|
2017-10-27 10:36:29 +00:00
|
|
|
sleep 6
|
2017-10-23 12:59:44 +00:00
|
|
|
|
|
|
|
n=0
|
|
|
|
while [ $n -lt 3 ]
|
|
|
|
do
|
2017-10-23 02:47:26 +00:00
|
|
|
python manage.py migrate
|
|
|
|
if [ $? -ne 0 ]; then
|
2017-10-23 12:59:44 +00:00
|
|
|
echo "Can't start server, try again in 3 seconds.."
|
|
|
|
sleep 3
|
|
|
|
let "n+=1"
|
|
|
|
continue
|
2017-10-23 02:47:26 +00:00
|
|
|
fi
|
2017-11-07 11:04:41 +00:00
|
|
|
python manage.py initinstall
|
2017-10-23 12:59:44 +00:00
|
|
|
break
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $n -eq 3 ]; then
|
|
|
|
echo "Can't start server, please check log file for details."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-11-01 14:25:14 +00:00
|
|
|
chown -R nobody:nogroup /data/log /data/test_case /data/avatar /data/upload
|
2017-10-23 12:59:44 +00:00
|
|
|
exec supervisord -c /app/deploy/supervisor.conf
|