1

更新我一直在四处寻找,看看重启后我的项目中可能需要重启哪些服务。其中一个在想狮身人面像,我终于到了它记录的地步:

[Fri Nov 16 19:34:29.820 2012] [29623] accepting connections

但我仍然无法运行 searchd 或 searchd --stop,因为在 etc/sphinxsearch 中没有生成 sphinx.conf 文件以获取更多信息,请参阅重新启动后在 thinking_sphinx上打开的线程

然后,根据我得到的一些见解,我转向研究重新启动独角兽或瘦身。问题是,当我检查我的宝石时,我看到一颗是瘦的和独角兽。但是当我尝试启动其中任何一个时,它们没有驻留在 nginx 和 sphinxsearch 文件所在的 etc/init.d/ 中的文件...

重新启动会完全清除瘦或独角兽等应用服务器的文件吗?我们托管在 Rackspace 上运行

红宝石 1.9.2p290
导轨(3.2.8、3.2.7、3.2.0)
nginx/1.1.19

  • 请注意,有独角兽和瘦的宝石,但我的应用程序的配置文件夹中没有 unicorn.rb 或 thin.rb ......如果有人能给我一些关于要采取的步骤的见解,我仍然非常迷茫我真的很感激。任何事情都会有所帮助,感谢阅读。

瘦 1.4.1
独角兽 4.3.1

当我运行独角兽时,我遇到了与此处引用的相同的问题

> /usr/local/bin/unicorn start

/usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.3.1/lib/unicorn/configurator.rb:610:in `parse_rackup_file': rackup file (start) not readable (ArgumentError)
from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.3.1/lib/unicorn/configurator.rb:76:in `reload'
from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.3.1/lib/unicorn/configurator.rb:67:in `initialize'
from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:104:in `new'
from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.3.1/lib/unicorn/http_server.rb:104:in `initialize'
from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.3.1/bin/unicorn:121:in `new'
from /usr/local/lib/ruby/gems/1.9.1/gems/unicorn-4.3.1/bin/unicorn:121:in `<top (required)>'
from /usr/local/bin/unicorn:19:in `load'
from /usr/local/bin/unicorn:19:in `<main>'

当我运行瘦时,它只会打开一个命令行提示符......

/usr/local/bin/thin start

>> Using rack adapter

其他宝石:

*当地宝石*

actionmailer (3.2.8, 3.2.7, 3.2.0)
actionpack (3.2.8, 3.2.7, 3.2.0)
activemodel (3.2.8, 3.2.7, 3.2.0)
activerecord (3.2.8, 3.2.7, 3.2.0)
activeresource (3.2.8, 3.2.7, 3.2.0)
activesupport (3.2.8, 3.2.7, 3.2.0)
arel (3.0.2)
builder (3.0.0)
bundler (1.1.5)
carmen (1.0.0.beta2)
carmen-rails (1.0.0.beta3)
cocaine (0.2.1)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.3.3)
daemons (1.1.9)
erubis (2.7.0)
eventmachine (0.12.10)
execjs (1.4.0)
faraday (0.8.4)
faraday_middleware (0.8.8)
foursquare2 (1.8.2)
geokit (1.6.5)
hashie (1.2.0)
hike (1.2.1)
httparty (0.8.3)
httpauth (0.1)
i18n (0.6.0)
journey (1.0.4)
jquery-rails (2.0.2)
json (1.7.4, 1.7.3)
jwt (0.1.5)
kgio (2.7.4)
lastfm (1.8.0)
libv8 (3.3.10.4 x86_64-linux)
mail (2.4.4)
mime-types (1.19, 1.18)
minitest (1.6.0)
multi_json (1.3.6)
multi_xml (0.5.1)
multipart-post (1.1.5)
mysql2 (0.3.11)
oauth2 (0.8.0)
paperclip (3.1.1)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.8, 3.2.7, 3.2.0)
railties (3.2.8, 3.2.7, 3.2.0)
raindrops (0.10.0, 0.9.0)
rake (0.9.2.2, 0.8.7)
rdoc (3.12, 2.5.8)
riddle (1.5.3)
sass (3.2.0, 3.1.19)
sass-rails (3.2.5)
sprockets (2.1.3)
sqlite3 (1.3.6)
sqlite3-ruby (1.3.3)
therubyracer (0.10.2, 0.10.1)
thin (1.4.1)
thinking-sphinx (2.0.10)
thor (0.16.0, 0.15.4, 0.14.6)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.33)
uglifier (1.2.7, 1.2.4)
unicorn (4.3.1)
xml-simple (1.1.1)

我正在做一个由另一个小组建造的项目。我对配置文件夹中的常量文件进行了一些修改(更改填充了一些下拉字段的数组的一些值),但必须重新启动应用程序才能识别这些更改。托管是通过 Rackspace 进行的,我们通过他们网站上的选项重新启动。我联系了他们并检查了我们服务器的状态,端口已打开且可操作。问题是当您转到该站点的地址时,该应用程序没有运行。然后,当我输入服务器的 IP 地址时,它只会显示“欢迎使用 Nginx”。但在日志文件中我看到:

[Thu Nov 15 02:34:37.945 2012] [15916] caught SIGTERM, shutting down
[Thu Nov 15 02:34:37.996 2012] [15916] shutdown complete

我不是很精通服务器端设置。我也从未参与过必须在应用程序启动之前启动特定服务的 Rails 项目。任何有关如何确定需要重新启动哪些服务以及如何重新启动它们的见解将不胜感激。这一刻,我感觉自己死在了水里……

谢谢,

艾伦

4

3 回答 3

1

Nginx 本身不会为 Rails 应用程序提供服务。它需要一个“应用服务器”,它可以将请求传递给并获得响应。有多种选择,最受欢迎的是Passenger、Thin 和Unicorn。我建议你从服务器上的 nginx 配置开始,看看是否提到了这些。这应该指向您如何重新启动它们。

http://www.modrails.com/documentation/Users%20guide%20Nginx.html

http://articles.slicehost.com/2008/5/27/ubuntu-hardy-nginx-rails-and-thin

http://sirupsen.com/setting-up-unicorn-with-nginx/(向下滚动到 Rails on Unicorns)

于 2012-11-15T21:25:12.553 回答
0

好的,经过数小时的搜索和尝试,我在网上找到了无数的东西,我从命令行运行了这个:

unicorn_rails -p 3000

就像魔术一样,该站点已重新启动并运行,现在我的问题是当我关闭控制台(我运行该命令)时,该站点再次出现故障。

我将按照这个希望解决这个问题

注意:这些是我为使事情正常工作而采取的步骤

重新启动服务器时,您必须重新启动一些服务才能访问应用程序:

1) thinking_sphinx
参考网站
http://pat.github.com/ts/en/rake_tasks.html
http://www.claytonlz.com/2010/09/thinkingsphinx-conf-problems/

a)create/modify  app/config/sphinx.yml

    development:
      morphology: stem_en
      port: 9312
      bin_path: "/usr/bin"             # set up the path to binary for searchd
      searchd_binary_name: searchd
      indexer_binary_name: indexer
      #mem_limit: 128M
    test:
      morphology: stem_en
      port: 9312
      mem_limit: 128M
    production:
      morphology: stem_en
      port: 9312
      mem_limit: 512M
    # the searchd ip, in case it's not on localhost
    # address: 10.10.0.0
    # this is by default included in db/sphinx
    # searchd_file_path: "/path/to/shared/folder/sphinx"

b)rake thinking_sphinx:index
c)rake thinking_sphinx:configure       # creates config/development.sphinx.conf which helps define sphinx's indexing

d)# then you have to start sphinx, there are 2 ways to do this

    rake thinking_sphinx:start
    rake thinking_sphinx:stop

    OR

    searchd
    searchd --stop

    # only the rake commands worked for me, when I tried to run searchd
    # I got an error FATAL: no readable config file (looked in /etc/sphinxsearch/sphinx.conf, ./sphinx.conf).
    # for some reason we dont have a sphinx.conf file, but the rake commands work without it

e)# once you start thinking_sphinx check log/searchd.log file for the line
    [Fri Nov 16 19:34:29.820 2012] [29623] accepting connections

2)nginx
参考站点:
http ://wiki.nginx.org/CommandLine

a) check that nginx is up and running
    i) start server 
        # to check where nginx resides type in this into server console
        which nginx
        # whatever path it gives you is how you start the server this is my path
        /usr/sbin/nginx 
    ii) stop server
        /usr/sbin/nginx -s stop # use the path given by which command

3)独角兽(启动应用服务器)
参考站点:
http ://codelevy.com/2010/02/09/getting-started-with-unicorn.html

a) test if unicorn will run after previous changes
    unicorn_rails -p 3000
    # the site should now be up and running, check that it is
    # console should now log the different actions you do on the site 

b) create unicorn.rb in config folder (if none is there)
    # only start this step if the step above got the site running
    # close the console or exit the process you started above
    # contents of unicorn.rb 
    worker_processes 2      #(starts 2 child processes, not completely neccissary)
    preload_app true
    timeout 30
    listen 3000

    after_fork do |server, worker|
      ActiveRecord::Base.establish_connection
    end

c) run unicorn in the background
    # make sure you exited the process above before running this
    unicorn_rails -c config/unicorn.rb -D

    # this was giving me an error that it said was logged by stderr
    # I got the command to run by adding a command to the front
    http://stackoverflow.com/questions/2325152/check-for-stdout-or-stderr

    exec 2> /dev/null unicorn_rails -c config/unicorn.rb -D


d) (optional) check stats from starting unicorn

    i) pgrep -lf unicorn_rails
        #sample output
        5374 unicorn_rails master -c config/unicorn.rb -D             
        5388 unicorn_rails worker[0] -c config/unicorn.rb -D    # not needed currently  
        5391 unicorn_rails worker[1] -c config/unicorn.rb -D    # not needed currently

    ii) cat tmp/pids/unicorn.pid # from inside the streetpotato folder
        #sample output
        5374
于 2012-11-16T21:54:28.480 回答
0

我知道我来晚了,但你正在运行的过程:

unicorn_rails -p 3000

默认情况下关闭会话时会死。如果您希望它继续运行而不死,请运行:

nohup unicorn_rails -p 3000 &

'nohup' 代表“无挂断”,即使在你掉线后也能保持进程运行。'&' 告诉操作系统在后台将其作为作业运行。

希望这能帮上忙!

于 2017-01-31T00:15:53.383 回答