0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AWS CodeStarのDjangoプロジェクトでgunicorn再起動設定

Posted at

AWS CodeStarで作成したDjangoプロジェクトが初期設定のままだとEC2インスタンスを再起動した時に自動でgunicornが起動しないので起動するように設定変更

supervisod.confを修正

パスを変更

[program:djangoproject]
command = /home/ec2-user/environment/bin/gunicorn -b 0.0.0.0:80 ec2django.wsgi

サービス化するファイルを作成

djangoはお好きな名前に変更

sudo vi /etc/init.d/django
#!/bin/sh
# chkconfig: 2345 99 10
# description: start django
# processname: django

start() {
       echo "start"
       source /home/ec2-user/environment/bin/activate
       export LD_LIBRARY_PATH="/usr/local/lib"
       /home/ec2-user/environment/bin/supervisord -c /home/ec2-user/supervisord.conf
}

stop() {
       echo "stop"
       pkill supervisord
}
case "$1" in
 start)
       start
       ;;
 stop)
       stop
       ;;
 restart)
       stop
       start
       ;;
esac

exit 0

サービスの登録

sudo chkconfig --add django
sudo chkconfig django on
sudo chmod u+x /etc/init.d/django 
sudo service django restart

再起動して画面が見えればOK

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?