Skip to content

Instantly share code, notes, and snippets.

@acro5piano
Last active September 6, 2016 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acro5piano/125a2cb52ce30ba5c86e to your computer and use it in GitHub Desktop.
Save acro5piano/125a2cb52ce30ba5c86e to your computer and use it in GitHub Desktop.
Sinatra + Thin + NginxでWEBアプリケーション運用 ref: http://qiita.com/acro5piano/items/1b63615a10e0ca4a67d7
require 'bundler/setup'
require 'sinatra/base'
class Application < Sinatra::Base
get '/' do
'hello,world!'
end
end
require './app'
run Application
.
|-- Gemfile
|-- app.rb
|-- config.ru
$ 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
$ 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
gem 'sinatra' , '1.4.6'
group :production do
gem 'thin'
end
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;
}
}
---
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