J-ogawa / isucon_dev

isucon本番の開発用ブランチ
0 stars 0 forks source link

リポジトリの準備 #5

Open J-ogawa opened 7 years ago

J-ogawa commented 7 years ago
  1. 設定ファイルの参照変更
    
    sudo cp /etc/nginx/nginx.conf etc/nginx/nginx.conf.bak
    sudo mv /etc/nginx/nginx.conf /home/ec2-user/config
    sudo ln -s /home/ec2-user/config/nginx.conf /etc/nginx/nginx.conf

/home/ec2-user/config/nginx.conf <- /etc/nginx/nginx.conf /home/ec2-user/config/limits.conf <- /etc/security/limits.conf /home/ec2-user/config/supervisord.conf <- /etc/supervisord.conf /home/ec2-user/config/my.cnf <- /etc/my.cnf /home/ec2-user/config/sysctl.conf <- /etc/sysctl.conf

sudo chown -R ec2-user:ec2-user config


2. アプリファイルの参照変更

as isucon cp -r webapp/ruby webapp/ruby_bak sudo mv webapp/ruby/ /home/ec2-user/ ln -s /home/ec2-user/ruby webapp/ruby

/home/ec2-user/ruby <- /home/isucon/webapp/ruby /home/ec2-user/public <- /home/isucon/webapp/public

sudo chown -R ec2-user:ec2-user /home/ec2-user/ruby sudo chown -R ec2-user:ec2-user /home/ec2-user/public


3. ローカルにscpでファイルダウンロード

scp -r ec2-user@....:/home/ec2-user/config . scp -r ec2-user@....:/home/ec2-user/ruby . scp -r ec2-user@....:/home/ec2-user/public .


4. deployスクリプト作成

ssh_host="ec2-user@52.197.135.194" cwd=dirname "${0}" expr "${0}" : "/.*" > /dev/null || cwd=(cd "${cwd}" && pwd)

rsync -av --exclude=".git/" --exclude="ruby/.bundle/" --exclude="ruby/vendor/bundle/*/" -e ssh "${cwd}/" "${ssh_host}:/home/ec2-user/"

ssh -t -t $ssh_host <<-EOS sudo sysctl -p echo "======================================================" ulimit -a echo "======================================================" sudo chmod -R 777 /home/ec2-user/ruby sudo su - isucon cd /home/isucon/webapp/ruby bundle install exit sudo service mysqld restart sudo service nginx restart sudo supervisorctl restart isucon_ruby exit EOS



5. deploy確認
hamadu commented 7 years ago

なるほど。supervisord もリポジトリに必要ですね。

konk303 commented 7 years ago

https://github.com/hamadu/isprac4/blob/master/deploy.sh https://github.com/k0kubun/isucon4-qualifier/blob/3855fbf93501ef09e237d552af22384cf11bc83a/deploy.sh