Ruby-on-rails 如何手动重启独角兽

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19352125/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 22:51:36  来源:igfitidea点击:

how to restart unicorn manually

ruby-on-railsunicorn

提问by BrainLikeADullPencil

I'm not confident that unicorn is restarting properly when I run cap deployas certain changes are not showing in the app, therefore I wanted to restart unicorn manually on my remote server. I have navigated into etc/init.dand see a listing for unicorn_myappbut it's not a directory (i.e. I can't cd into it). Based on the code below from my deploy.rb file, is there something I can do from here to restart unicorn?

我不确定当我运行时 unicorn 是否正确重新启动cap deploy,因为应用程序中没有显示某些更改,因此我想在我的远程服务器上手动重新启动 unicorn。我已经导航etc/init.d并看到了一个列表,unicorn_myapp但它不是一个目录(即我不能进入它)。根据我的 deploy.rb 文件中的以下代码,我可以从这里做些什么来重新启动独角兽?

I tried to do run unicorn_myapp restartbut it said runisn't a command

我试图做,run unicorn_myapp restart但它说run不是命令

namespace :deploy do
  %w[start stop restart].each do |command|
    desc "#{command} unicorn server"
    task command, roles: :app, except: {no_release: true} do
      run "/etc/init.d/unicorn_#{application} #{command}"
    end
  end

回答by Doon

you didn't list the OS. but one of the following should work.

你没有列出操作系统。但以下之一应该有效。

you will need to be root / use sudo

您将需要成为 root / 使用 sudo

/etc/init.d/unicorn_myapp restart 


/etc/init.d/unicorn_myapp stop 
/etc/init.d/unicorn_myapp start 


service unicorn_myapp restart

service unicorn_myapp stop
service unicorn_myapp start

Try the restart versions first, but depending upon how the init script was written it might not have a restart command, if that doesn't work you can do the stop / start version.

首先尝试重新启动版本,但根据 init 脚本的编写方式,它可能没有重新启动命令,如果这不起作用,您可以执行停止/启动版本。

回答by Vincent Guerci

Alternatively, instead of relying on /etc/init.d...scripts which are OS dependent, a simple way to restart unicorn is to send HUP (1)signal to its master process.

或者,不是依赖依赖于/etc/init.d...操作系统的脚本,重启 unicorn 的一种简单方法是HUP (1)向其主进程发送信号。

Here is for instance how I reload an app automatically after a git pushvia post-receivehook:

例如,以下是我如何在git pushviapost-receive挂钩后自动重新加载应用程序:

#!/bin/sh
unicorn_pid=`cat /tmp/pids/unicorn.pid`
echo "Restarting Unicorn ($unicorn_pid)"
kill -HUP $unicorn_pid

In your case, /etc/init.d/unicorn_myapp restartscript is probably doing this. Check the unicorn.conf for the location of its pidfile.

在您的情况下,/etc/init.d/unicorn_myapp restart脚本可能正在执行此操作。检查 unicorn.conf 以获取其 pidfile 的位置。

For more details, see unicorn SIGNALS documentations

有关更多详细信息,请参阅unicorn SIGNALS 文档

回答by wwwslinger

You might have to be root, but it should just be /etc/init.d/unicorn_myapp restart(don't include run, which is not a shell command).

您可能必须是 root,但它应该只是/etc/init.d/unicorn_myapp restart(不要包含run,这不是 shell 命令)。