Last active
September 6, 2016 16:44
-
-
Save acro5piano/125a2cb52ce30ba5c86e to your computer and use it in GitHub Desktop.
Sinatra + Thin + NginxでWEBアプリケーション運用 ref: http://qiita.com/acro5piano/items/1b63615a10e0ca4a67d7
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
require 'bundler/setup' | |
require 'sinatra/base' | |
class Application < Sinatra::Base | |
get '/' do | |
'hello,world!' | |
end | |
end |
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
require './app' | |
run Application |
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
. | |
|-- Gemfile | |
|-- app.rb | |
|-- config.ru |
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
$ which bundle | |
/home/kazuya/.rbenv/shims/bundle | |
$ sudo /home/kazuya/.rbenv/shims/bundle exec thin install | |
Installing thin service at /etc/init.d/thin ... | |
mkdir -p /etc/init.d | |
writing /etc/init.d/thin | |
chmod +x /etc/init.d/thin | |
mkdir -p /etc/thin | |
To configure thin to start at system boot: | |
on RedHat like systems: | |
sudo /sbin/chkconfig --level 345 thin on | |
on Debian-like systems (Ubuntu): | |
sudo /usr/sbin/update-rc.d -f thin defaults | |
on Gentoo: | |
sudo rc-update add thin default | |
$ sudo /usr/sbin/update-rc.d -f thin defaults |
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
$ which bundle | |
/home/kazuya/.rbenv/shims/bundle | |
$ sudo /home/kazuya/.rbenv/shims/bundle exec thin install | |
Installing thin service at /etc/init.d/thin ... | |
mkdir -p /etc/init.d | |
writing /etc/init.d/thin | |
chmod +x /etc/init.d/thin | |
mkdir -p /etc/thin | |
To configure thin to start at system boot: | |
on RedHat like systems: | |
sudo /sbin/chkconfig --level 345 thin on | |
on Debian-like systems (Ubuntu): | |
sudo /usr/sbin/update-rc.d -f thin defaults | |
on Gentoo: | |
sudo rc-update add thin default | |
$ sudo /usr/sbin/update-rc.d -f thin defaults |
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
gem 'sinatra' , '1.4.6' | |
group :production do | |
gem 'thin' | |
end |
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
upstream backend { | |
server unix:/tmp/hoge.1.sock; | |
ip_hash; | |
} | |
server { | |
listen 80; | |
listen 443; | |
server_name hoge-service.com; | |
ssl on; | |
ssl_certificate /etc/nginx/ssl-files/server.crt; | |
ssl_certificate_key /etc/nginx/ssl-files/server.key; | |
location / { | |
proxy_pass http://backend; | |
} | |
} |
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
--- | |
chdir: /path/to/your/application | |
environment: production | |
timeout: 30 | |
log: log/thin.log | |
pid: tmp/pids/thin.pid | |
max_conns: 1024 | |
max_persistent_conns: 100 | |
require: [] | |
wait: 30 | |
threadpool_size: 20 | |
socket: /tmp/hoge.1.sock | |
daemonize: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment