Last active
December 19, 2015 05:48
-
-
Save keokent/5906266 to your computer and use it in GitHub Desktop.
Puppetで構築したVMにRailsアプリを入れて、Unicornを起動する。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
appuserのホームディレクトリにsample_appをgit clone | |
[keoken@app002]~% sudo -u appuser sh -c 'cd /home/appuser;git clone https://github.com/keokent/sample_app.git' | |
その前に | |
rubyがちゃんと入ってなかった疑惑 | |
ruby -vをたたくとデフォルトで入っているrubyが指定されている | |
bash -c 'ruby -v'とやるとruby-2.0.0-p195が指定されてた | |
ちゃんと入ってるみたいだった | |
/home/appuser/sample_app内で bundle installをする | |
bundle install --path vendor/bundlerとやると | |
/usr/local/rbenv/versions/2.0.0-p195内ではなく | |
home/appuser/sample_app内に vendor/bundlerディレクトリを作り | |
そこにインストールするらしい | |
データベースのマイグレートをしていく | |
[appuser@app002 sample_app]$ RAILS_ENV=production bundle exec rake db:migrate | |
怒られた | |
[appuser@app002 sample_app]$ RAILS_ENV=production bundle exec rake db:migrate | |
rake aborted! | |
Access denied for user 'keoken'@'localhost' (using password: YES) | |
database.yml内のパスワード指定が違った | |
[appuser@app002 sample_app]$ emacs config/database.yml | |
[appuser@app002 sample_app]$ RAILS_ENV=production bundle exec rake db:migrate | |
また怒られた | |
[appuser@app002 sample_app]$ RAILS_ENV=production bundle exec rake db:populate | |
rake aborted! | |
Unknown database 'sample_app_production' | |
データベース作ってなかった | |
[appuser@app002 sample_app]$ RAILS_ENV=production bundle exec rake -T コマンドを調べる | |
[appuser@app002 sample_app]$ RAILS_ENV=production bundle exec rake db:create | |
[appuser@app002 sample_app]$ RAILS_ENV=production bundle exec rake db:migrate | |
[appuser@app002 sample_app]$ RAILS_ENV=production bundle exec rake db:populate | |
[appuser@app002 sample_app]$ RAILS_ENV=production bundle exec rake assets:precompile | |
これでおっけい | |
ユニコーン起動! | |
[appuser@app002 sample_app]$ bundle exec unicorn -c /home/appuser/sample_app/config/unicorn.rb --env production | |
master failed to start, check stderr log for details ぐへえ | |
再起動とかしてみる | |
[keoken@app002 sample_app_puppet]$ sudo service nginx restart | |
だめだった | |
エラーログを調べる | |
[appuser@app002 sample_app]$ cat config/shared/log/unicorn.stderr.log | |
/home/appuser/sample_app/vendor/bundle/ruby/2.0.0/gems/unicorn-4.6.2/lib/unicorn/socket_helper.rb:140:in `initialize': No such file or directory - "/home/appuser/sample_app/tmp/sockets/.unicorn.sock" (Errno::ENOENT) | |
tmp/socketsディレクトリがなかった | |
[appuser@app002 sample_app]$ mkdir tmp/sockets | |
[appuser@app002 sample_app]$ bundle exec unicorn -c /home/appuser/sample_app/config/unicorn.rb --env production -D | |
ブラウザで確認 | |
なんか見れない こまった | |
過去のgistにより/home/appuserのpermissionがいけないのではと | |
検討をつける | |
[appuser@app002 sample_app]$ stat /home/appuser | |
File: `/home/appuser' | |
Size: 4096 Blocks: 8 IO Block: 4096 ディレクトリ | |
Device: fd00h/64768d Inode: 31413 Links: 5 | |
Access: (0700/drwx------) Uid: ( 1000/ appuser) Gid: ( 1000/ appuser) | |
Access: 2013-07-01 14:29:11.603446176 +0900 | |
Modify: 2013-07-01 14:28:01.567444115 +0900 | |
Change: 2013-07-01 14:28:01.567444115 +0900 | |
やはりいけなかった | |
[appuser@app002 sample_app]$ chmod 755 /home/appuser | |
みれたあああ | |
なんか見れない こまった
ここはログを追って確認する癖もつけよう。今回の場合は /var/log/nginx/* かな。
過去のgistにより/home/appuserのpermisonがいけないのではと
permison -> permission !
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
の部分は serverspec に記述しておくといいね。忘れがちな仕様どをテストで補強しておきましょう