StupidBeauty
Read times:3251Posted at:Tue Nov 1 13:01:56 2016 - no title specified

Thin文档翻译:Thin

一个小巧且快速的Ruby网页服务器

安装

gem install thin

或者 thin 加入到妳的 Gemfile 中:

gem 'thin'

使用

狠容易就能使用thin脚本来启动Rack 应用程序:

thin start

可在 example 目录中观摩更多示例应用程序。

与Rails Action Cable配套使用

要将Thin 与Action Cable 配套使用,则向 Gemfile 中加入以下代码:

gem 'faye-websocket'

gem 'thin' # 如果之前 没加入的话,现在是时候加入了

创建 一个文件 config/initializers/thin_action_cable.rb

Rails.application.config.action_cable.use_faye = true

Faye::WebSocket.load_adapter 'thin'

命令行用法

使用rackup配置文件(config.ru),并且绑定到本机本地网卡的8080 端口:

thin -R config.ru -a 127.0.0.1 -p 8080 start

将服务器进程编号和日志写入到文件中,并且以守护进程模式运行:

thin -p 9292 -P tmp/pids/thin.pid -l logs/thin.log -d start

Thin 使用起来狠灵活,狠多选项都可以通过命令行指定 (具体参考 thin -h )

配置文件

可使用此命令来创建一个配置文件: thin config -C config/thin.yml

然后 ,可以在所有相关命令中使用这个配置文件,例如: thin start -C config/thin.yml

以下是一个示例配置文件:

---

user: www-data

group: www-data

pid: tmp/pids/thin.pid

timeout: 30

wait: 30

log: log/thin.log

max_conns: 1024

require: []

environment: production

max_persistent_conns: 512

servers: 1

threaded: true

no-epoll: true

daemonize: true

socket: tmp/sockets/thin.sock

chdir: /path/to/your/apps/root

tag: a-name-to-show-up-in-ps aux

武大: 悔不该让西门庆做经纪人 ′′′′′′

Your opinions

Your name:Email:Website url:Opinion content: