ruby-on-rails – 如何使用美洲狮的配置文件?

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 如何使用美洲狮的配置文件?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在关注 this guide,它记录了存储在应用程序的config目录中的puma.rb文件.

该指南有点flakey,但这是我假设puma.rb文件.而不是运行这样的疯狂命令,以获得美洲豹在指定的套接字上运行:

  1. bundle exec puma -e production -b unix:///var/run/my_app.sock

您可以在puma.rb文件中指定端口,pid,会话和其他参数,如下所示:

  1. rails_env = ENV['RAILS_ENV'] || 'production'
  2.  
  3. threads 4,4
  4.  
  5. bind "/home/starkers/Documents/alpha/tmp/socket"
  6. pidfile "/home/starkers/Documents/alpha/tmp/pid"
  7. state_path "/home/starkers/Documents/alpha/tmp/state"
  8.  
  9. activate_control_app

然后你可以cd进入应用程序的根目录并运行一个简单的命令

“彪马”

并且将遵循在puma.rb中设置的参数.不幸的是,这似乎不适合我.

至少,我在一个小测试应用程序的根目录下运行了美洲狮,没有.sock文件出现
/ home / starkers / Documents / alpha / tmp / sockets是不是意味着它不工作?

我该如何让这个工作?我在一台本地开发机器上,那可能会导致这个错误呢?是否有一个参数,我需要在运行时传入

美洲狮

解决方法

我也试图找到关于美洲狮配置文件的文档,但我确实发现 the all-in-one config.ru文件有用.我已将格式化在此以备将来参考:
  1. # The directory to operate out of.
  2. # The default is the current directory.
  3.  
  4. directory '/u/apps/lolcat'
  5.  
  6. # Load “path” as a rackup file.
  7. # The default is “config.ru”.
  8.  
  9. rackup '/u/apps/lolcat/config.ru'
  10.  
  11. # Set the environment in which the rack's app will run. The value must be a string.
  12. # The default is “development”.
  13.  
  14. environment 'production'
  15.  
  16. # Daemonize the server into the background. Highly suggest that
  17. # this be combined with “pidfile” and “stdout_redirect”.
  18. # The default is “false”.
  19.  
  20. daemonize
  21. daemonize false
  22.  
  23. # Store the pid of the server in the file at “path”.
  24.  
  25. pidfile '/u/apps/lolcat/tmp/pids/puma.pid'
  26.  
  27. # Use “path” as the file to store the server info state. This is
  28. # used by “pumactl” to query and control the server.
  29.  
  30. state_path '/u/apps/lolcat/tmp/pids/puma.state'
  31.  
  32. # Redirect STDOUT and STDERR to files specified. The 3rd parameter
  33. # (“append”) specifies whether the output is appended,the default is
  34. # “false”.
  35.  
  36. stdout_redirect '/u/apps/lolcat/log/stdout','/u/apps/lolcat/log/stderr'
  37. stdout_redirect '/u/apps/lolcat/log/stdout','/u/apps/lolcat/log/stderr',true
  38.  
  39. # Disable request logging.
  40. # The default is “false”.
  41.  
  42. quiet
  43.  
  44. # Configure “min” to be the minimum number of threads to use to answer
  45. # requests and “max” the maximum.
  46. # The default is “0,16”.
  47.  
  48. threads 0,16
  49.  
  50. # Bind the server to “url”. “tcp://”,“unix://” and “ssl://” are the only
  51. # accepted protocols.
  52. # The default is “tcp://0.0.0.0:9292”.
  53.  
  54. bind 'tcp://0.0.0.0:9292'
  55. bind 'unix:///var/run/puma.sock'
  56. bind 'unix:///var/run/puma.sock?umask=0777'
  57. bind 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'
  58.  
  59. # Listens on port 7001
  60. # The default is 9292
  61. port 7001
  62.  
  63. # Instead of “bind 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'” you
  64. # can also use the “ssl_bind” option.
  65.  
  66. ssl_bind '127.0.0.1','9292',{ key: path_to_key,cert: path_to_cert }
  67.  
  68. # Code to run before doing a restart. This code should
  69. # close log files,database connections,etc.
  70.  
  71. # This can be called multiple times to add code each time.
  72.  
  73. on_restart do
  74. puts 'On restart...'
  75. end
  76.  
  77. # Command to use to restart puma. This should be just how to
  78. # load puma itself (ie. 'ruby -Ilib bin/puma'),not the arguments
  79. # to puma,as those are the same as the original process.
  80.  
  81. restart_command '/u/app/lolcat/bin/restart_puma'
  82.  
  83. # === Cluster mode ===
  84.  
  85. # How many worker processes to run.
  86. # The default is “0”.
  87.  
  88. workers 2
  89.  
  90. # Code to run when a worker boots to setup the process before booting
  91. # the app.
  92. # This can be called multiple times to add hooks.
  93.  
  94. on_worker_boot do
  95. puts 'On worker boot...'
  96. end
  97.  
  98. # === Puma control rack application ===
  99.  
  100. # Start the puma control rack application on “url”. This application can
  101. # be communicated with to control the main server. Additionally,you can
  102. # provide an authentication token,so all requests to the control server
  103. # will need to include that token as a query parameter. This allows for
  104. # simple authentication.
  105.  
  106. # Check out https://github.com/puma/puma/blob/master/lib/puma/app/status.rb
  107. # to see what the app has available.
  108.  
  109. activate_control_app 'unix:///var/run/pumactl.sock'
  110. activate_control_app 'unix:///var/run/pumactl.sock',{ auth_token: '12345' }
  111. activate_control_app 'unix:///var/run/pumactl.sock',{ no_token: true }

那些设置然后会进入一个ruby文件(例如config / puma.rb),然后Starkers说,你可以运行它

puma -C config/puma.rb

猜你在找的Ruby相关文章