`

unicorn.rb 配置

 
阅读更多
# Sample verbose configuration file for Unicorn (not Rack)
#
# This configuration file documents many features of Unicorn
# that may not be needed for some applications. See
# http://unicorn.bogomips.org/examples/unicorn.conf.minimal.rb
# for a much simpler configuration file.
#
# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
# documentation.

# Use at least one worker per core if you're on a dedicated server,
# more will usually help for _short_ waits on databases/caches.
rails_env = ENV['RAILS_ENV'] || 'production'
# 10 workers and 1 master
worker_processes (rails_env == 'production' ? 10 : 2)
#worker_processes 4
# Since Unicorn is never exposed to outside clients, it does not need to
# run on the standard HTTP port (80), there is no reason to start Unicorn
# as root unless it's from system init scripts.
# If running the master process as root and the workers as an unprivileged
# user, do this to switch euid/egid in the workers (also chowns logs):
# user "unprivileged_user", "unprivileged_group"

# Help ensure your application will always spawn in the symlinked
# "current" directory that Capistrano sets up.
# run  unicorn_rails -c /wwwroot/yourapp/config/unicorn.rb -E production -D
#APP_PATH = File.expand_path(File.dirname(File.dirname(__FILE__)))
APP_PATH ="/home/dong/workspace/blog"
working_directory APP_PATH # available in 0.94.0+

# listen on both a Unix domain socket and a TCP port,
# we use a shorter backlog for quicker failover when busy
#listen "/tmp/nginx/sockets/unicorn.sock", :backlog => 64
#listen "/tmp/.sock", :backlog => 64
listen APP_PATH+"/tmp/nginx/sockets/unicorn.sock", :backlog => 64
listen 8080, :tcp_nopush => true
# nuke workers after 30 seconds instead of 60 seconds (the default)
timeout 30
# feel free to point this anywhere accessible on the filesystem
#pid "/path/to/app/shared/pids/unicorn.pid"
pid APP_PATH + "/tmp/pid/unicorn.pid"
# By default, the Unicorn logger will write to stderr.
# Additionally, ome applications/frameworks log to stderr or stdout,
# so prevent them from going to /dev/null when daemonized here:
#stderr_path "/path/to/app/shared/log/unicorn.stderr.log"
#stdout_path "/path/to/app/shared/log/unicorn.stdout.log"
stderr_path APP_PATH + "/log/unicorn.stderr.log"
stdout_path APP_PATH + "/log/unicorn.stdout.log"
# combine REE with "preload_app true" for memory savings
# http://rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
preload_app true
GC.respond_to?(:copy_on_write_friendly=) and
GC.copy_on_write_friendly = true

before_fork do |server, worker|
# the following is highly recomended for Rails + "preload_app true"
# as there's no need for the master process to hold a connection
defined?(ActiveRecord::Base) and
  ActiveRecord::Base.connection.disconnect!

# The following is only recommended for memory/DB-constrained
# installations.  It is not needed if your system can house
# twice as many worker_processes as you have configured.
#
# # This allows a new master process to incrementally
# # phase out the old master process with SIGTTOU to avoid a
# # thundering herd (especially in the "preload_app false" case)
# # when doing a transparent upgrade.  The last worker spawned
# # will then kill off the old master process with a SIGQUIT.
# old_pid = "#{server.config[:pid]}.oldbin"
# if old_pid != server.pid
#   begin
#     sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
#     Process.kill(sig, File.read(old_pid).to_i)
#   rescue Errno::ENOENT, Errno::ESRCH
#   end
# end
#
# Throttle the master from forking too quickly by sleeping.  Due
# to the implementation of standard Unix signal handlers, this
# helps (but does not completely) prevent identical, repeated signals
# from being lost when the receiving process is busy.
# sleep 1
end

after_fork do |server, worker|
# per-process listener ports for debugging/admin/migrations
# addr = "127.0.0.1:#{9293 + worker.nr}"
# server.listen(addr, :tries => -1, :delay => 5, :tcp_nopush => true)
# the following is *required* for Rails + "preload_app true",
defined?(ActiveRecord::Base) and
  ActiveRecord::Base.establish_connection
# if preload_app is true, then you may also want to check and
# restart any other shared sockets/descriptors such as Memcached,
# and Redis.  TokyoCabinet file handles are safe to reuse
# between any number of forked children (assuming your kernel
# correctly implements pread()/pwrite() system calls)
end
分享到:
评论

相关推荐

    nginx-unicorn-config:Nginx和Unicorn的样板配置文件

    您将需要在/var/www/app/unicorn.rb编辑Unicorn配置文件 样本配置文件包含在此存储库中。 ##运行此脚本 登录到您的Droplet。 在文本编辑器中打开一个新文件,然后将的内容复制到其中。 示例: nano s

    利用Unicorn和Nginx部署Redmine

    3. **配置Unicorn**:编写Unicorn配置文件(如`config/unicorn.rb`),指定工作进程数量、日志位置等参数。 4. **启动Unicorn**:通过命令行启动Unicorn服务,如` unicorn_rails -c config/unicorn.rb -E ...

    trackvue:追踪视频

    unicorn_rails –配置文件config / unicorn.rb #서버에서는이렇게실행함。 unicorn_rails -c /var/www/trackvue/config/unicorn.server.rb -D #production모드에가제가있음.. unicorn_rails -c /var/...

    mini-tower:小型塔

    修改config目录下的unicorn.rb后手动unicorn -D -c application_location_path/config/unicorn.rb -E production启动,或者可以通过修改unicorn_init.sh后,建立软链到/etc/init.d/unicorn,通过service unicorn ...

    guorj-ruby:http

    unicorn_rails -c config/unicorn.rb -E production -D 此自述文件通常会记录启动和运行应用程序所需的任何步骤。 您可能想要涵盖的内容: Ruby版 系统依赖 配置 数据库创建 数据库初始化 如何运行测试套件 服务...

    devops-test-day-app:天气控制API

    d.weather API 天气报告和天气控制API。...运行特殊命令以启动应用程序存储库中的应用程序服务器( unicorn_rails -D -c config/unicorn.rb )-应用程序服务器在localhost:8080上运行localhost:808

    Gitlab的安装及使用.docx

    Gitlab 的配置文件 gitlab.rb 是 Gitlab 的核心配置文件,用于配置 Gitlab 的各种参数,包括数据库连接、邮件发送、缓存等。在安装完成后需要修改这个文件以适应自己的需求。 在使用 Gitlab 时需要注意 Gitlab 的...

    Linux系统上配置Nginx+Ruby on Rails+MySQL超攻略

    创建一个Unicorn配置文件,例如`config/unicorn.rb`,包含以下内容: ```ruby worker_processes 2 timeout 30 APP_PATH = File.expand_path("../..", __FILE__) working_directory APP_PATH listen 8080, :tcp_no...

    fll-site:雏鸟语言列表的来源

    `unicorn.rb`是配置文件,包含了Unicorn服务器运行时的参数设置,如工作进程数量、端口、日志文件等。通过`bundle exec`执行这个命令,确保在项目的Gem环境中运行Unicorn,避免了版本冲突的问题。 标签“HTML”表明...

    Rina_Blog:个人博客系统1.0

    rina的博客 1.0博客已经废弃,最新...先根据项目里的/config/deploy.rb /config/unicorn/production.rb /config/nigix.conf文件,修改其中的配置,然后将/config/nigix.conf文件复制到你的服务器上的nginx所在目录的

    centos7.5安装gitlab和gitlab备份迁移恢复.docx

    在安装完成后,需要编辑 GitLab 的配置文件 `/etc/gitlab/gitlab.rb`,将 `external_url` 配置为自己的服务器 IP 和端口号: ``` vim /etc/gitlab/gitlab.rb external_url http://IP:端口 ``` 然后,需要执行配置...

    Gitlab备份恢复与迁移.doc

    可以通过/etc/gitlab/gitlab.rb配置文件来修改备份文件的存放目录。例如,要将备份文件存放到/mnt/backups目录下,可以修改配置文件中的以下代码:gitlab_rails['backup_path'] = '/mnt/backups'。然后,使用以下...

    gitLab 使用教程.pdf

    5. 修改`/etc/gitlab/gitlab.rb`中的`external_url`,设置GitLab的访问地址。 6. 再次运行`gitlab-ctl reconfigure`使配置生效,并重启GitLab (`gitlab-ctl restart`)。 7. 测试GitLab是否可正常访问。 8. 如需汉化...

    Travel-app:Travel 应用程序是一个简单的 Ruby on Rails 应用程序,可显示所有标签及其目的地

    Rails应用可以通过`rails server`命令本地运行,但正式上线时通常会配合 Passenger、Puma 或 Unicorn 等服务器软件。 以上就是关于"Travel-app"这个Ruby on Rails项目的相关技术点,它体现了Rails的快速开发能力,...

    capistrano-recipes:我们的Capistrano食谱

    unicornherder ,由主管监控(在9001端口运行其Web界面),以管理unicorn实例delayed_job的运行后台处理,如果use_delayed_job标志在设置deploy.rb 。 monit (在端口2812上运行其Web界面)来管理数据库( mysql或...

    Gitlab备份及迁移恢复

    gitlab-ctl stop unicorn gitlab-ctl stop sidekiq ``` 6. **执行恢复操作** 使用以下命令从备份文件中恢复GitLab: ```bash gitlab-rake gitlab:backup:restore BACKUP=1502357536 ``` 在恢复过程中可能...

    8.2 gitlab安装和使用1

    主配置文件位于`/etc/gitlab/gitlab.rb`,GitLab的文档根目录为`/opt/gitlab`,默认的仓库存储位置为`/var/opt/gitlab/git-data/repositories`,Nginx的配置文件路径是`/var/opt/gitlab/nginx/conf/gitlab-...

    Ruby编写Puma Web服务器 v6.4.2

    在配置方面,Puma提供了`.puma.rb`配置文件,允许你定制服务器的行为,如设置最小和最大线程数、工作进程数量以及绑定的网络接口等。例如,`threads_min, threads_max`可以设定线程池的大小,`workers count`可以...

    基于ruby on rails 的简单blog

    4. **性能**:虽然不如Java或C++,但通过优化和使用如Puma、Unicorn等服务器,Rails应用也能有较好的性能表现。 这个简单的blog项目是初学者了解Rails的好起点,通过实践,可以掌握Rails的基本用法,进一步深入学习...

Global site tag (gtag.js) - Google Analytics