script-code-update.sh 997 B

1234567891011121314151617181920212223
  1. #!/bin/bash
  2. # 更新代码
  3. su -c "cd /code && git pull || git reset --hard FETCH_HEAD" -s /bin/bash - www-data
  4. su -c "cd /code && git checkout $PROGINN_BRANCH" -s /bin/bash - www-data
  5. cd /code && current_git_branch_latest_id=`git rev-parse HEAD`
  6. current_git_branch_last_id=`cat /data/.proginn-commit-id`
  7. if [[ "$current_git_branch_latest_id" != "$current_git_branch_last_id" ]]; then
  8. echo "$current_git_branch_latest_id" > /data/.proginn-commit-id
  9. # 同步crontab
  10. cronfile=/code/config/php7/web/cron.test
  11. cp $cronfile /etc/crontab
  12. echo "*/2 * * * * root bash /data/docker/shell/script-code-update.sh\n" >> /etc/crontab
  13. # 启动定时脚本
  14. service cron restart
  15. # 队列
  16. ps axu |grep resque.php | awk '{print $2}'|xargs kill -15
  17. ps axu |grep resque.php | awk '{print $2}'|xargs kill -9
  18. for (( i = 0; i < 5; i++ )); do
  19. su -c "QUEUE=highest,high,default,low,lowest COUNT=1 nohup php /code/web/bin/resque.php &" -s /bin/bash - www-data
  20. done
  21. fi