月別アーカイブ: 2017年11月

ニコ動再課金

自分が作ったゲームをしてくれてる

ニコ生のタイムシフトが最近増えて、

気軽に見たかったので再課金してしまう。

月間540円で色々チェックできてゲームの品質良くならいいか。

ruby on railsを5年ぶりぐらいに触ってみた

phpからrubyへの流れがあるので、次回のアプリで採用してみたい。
5年前はrails3だったきがするけど、rails5にあがってた。

とりあえず、Ruby本体をrbenvで入れてみる。

$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
$ exec $SHELL
$ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
$ echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc
$ exec $SHELL
$ rbenv -v
$ rbenv install --list
$ rbenv install 2.4.2
$ rbenv global 2.4.2
$ rbenv versions
> * 2.4.2 (set by /home/linux/.rbenv/version)
$ rbenv rehash
$ ruby -v
> ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]

railsのインストール
$ gem search -r rails
$ gem install rails
$ rails -v
> Rails 5.1.4

webrick(port3000)で起動したけど・・・
$ gem install bundler
$ bundle install
$ rails server

デーモンではないのでやめる。

unicornというrubyアプリサーバがあるらしいのでそれを入れる。
config/unicorn.rb
rails_root = File.expand_path('../../', __FILE__)
worker_processes 2
working_directory rails_root
listen "#{rails_root}/tmp/unicorn.sock"
pid "#{rails_root}/tmp/unicorn.pid"
stderr_path "#{rails_root}/log/unicorn_error.log"
stdout_path "#{rails_root}/log/unicorn.log"
listen 8080

port8080で起動確認。

nginxとunicornは相性がいいようなのでnginxの設定を追加
upstream unicorn_server {
server unix:/home/linux/helloworld/tmp/unicorn.sock;
}
server {
listen 80;
server_name localhost;
root /home/linux/helloworld/public;
access_log /var/log/nginx/ruby_helloworld_access.log;
error_log /var/log/nginx/ruby_helloworld_error.log;
client_max_body_size 100m;
error_page 500 502 503 504 /500.html;
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_pass http://unicorn_server;
}
}

無事port80で起動できた。