码迷,mamicode.com
首页 > 其他好文 > 详细

django自动化部署脚本

时间:2014-09-12 18:47:43      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   ar   for   div   sp   

while read line;do
    echokill $line;
    kill $line;
done < /tmp/celeryd.pid

while read line;do
    echokill $line;
    kill $line;
done < /tmp/runserver.pid
ps -ef | grep runserver | awk {print $2;} | xargs -i -t kill {}

git pull

pip install -r requirements.txt -i http://pypi.douban.com/simple

cur_time=$(date +%Y%m%d%H%M%s)
db_name=/tmp/db/dkhs_${cur_time}.json
echo ${db_name}

if [ -d /tmp/db ]
then 
    echo /tmp/db exists
else
    mkdir /tmp/db 
    echo /tmp/db create success
fi

# backup database dkhs
python coresite/manage.py dumpdata --format=json accounts conference socialgraph portfolio statuses > ${db_name}

# drop all table except finace table
mysql -h 192.168.107.253 -udkhs_data -pdkhs_data -e "use dkhs; show tables;" | egrep -v "finance|Tables_in_dkhs" | xargs -i -t mysql -h 192.168.107.253 -udkhs_data -pdkhs_data -e "use dkhs;SET foreign_key_checks = 0;drop table if exists {}"

# syncdb without init data
python coresite/manage.py syncdb --noinput --migrate --no-initial-data 

# syncdb with init data
#python coresite/manage.py syncdb --noinput --migrate

# use backupdata recover database
python coresite/manage.py loaddata ${db_name}

# insert local client id
python coresite/manage.py loaddata coresite/coresite/fixtures/initial_data.json


##mysql -uroot -proot -e "drop database if exists dkhs ;create database dkhs character set utf8;"
##python coresite/manage.py syncdb --noinput --migrate
##mysql -uroot -proot dkhs < ~/init_stock.sql
##echo "from accounts.models import User; User.objects.create_superuser(‘dkhs‘, ‘dkhs@dkhs.com‘, ‘dkhs‘)" | coresite/manage.py shell


export C_FORCE_ROOT="1"
python coresite/manage.py celeryd -l info -f /tmp/celeryd.log --pidfile=/tmp/celeryd.pid &


python coresite/manage.py runserver 0.0.0.0:8000 &
echo $! > /tmp/runserver.pid

 

django自动化部署脚本

标签:style   blog   http   color   io   ar   for   div   sp   

原文地址:http://www.cnblogs.com/linjiqin/p/3968815.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!