简体   繁体   English

在使用Rails 3的Ubuntu上启动Nginx / Passenger(非独立)的正确方法?

[英]Proper way to start nginx/passenger (non-standalone) on Ubuntu with Rails 3?

I configured my Rails 3 production app about 6 months ago on Ubuntu running nginx/passenger, using git and Capistrano for deployment. 大约6个月前,我使用git和Capistrano在运行nginx / passenger的Ubuntu上配置了我的Rails 3生产应用程序。

Fast forward to last week - The data center I was using (DigitalOcean NYC) actually had a complete power failure (and the battery backup didn't work) - resulting in my server shutting completely down. 快进上周-我正在使用的数据中心(DigitalOcean NYC)实际上完全断电(并且备用电池不起作用)-导致服务器完全关闭。

I did not set passenger or mysql to start on reboot, so when the hardware server restarted, my app was still down. 我没有设置乘客或mysql在重新启动时启动,因此当硬件服务器重新启动时,我的应用程序仍然关闭。

I really did not know much about what I was doing at the time when I launched it (since it was my first production server that I have worked with), and I followed a guide to get it up and running. 我真的不太了解启动时的操作(因为这是我与之合作的第一台生产服务器),因此我遵循了指南来启动和运行它。

When I attempted to get the app running again, I managed to start mysqld no problem - but for the life of me couldn't remember how to get nginx/passenger running again. 当我尝试再次运行该应用程序时,我成功启动mysqld没问题-但是我一生都不记得如何重新启动nginx / passenger。

Since time was of the essence (my client needed the app up and running ASAP), I ended up getting the app back up and running by navigating to my app directory (/current) and using the command: 由于时间至关重要(我的客户端需要尽快启动并运行该应用程序),因此我通过导航至我的应用程序目录(/当前)并使用以下命令来使该应用程序重新启动并运行:

passenger start -p 80 -e production

This did the trick but actually started Passenger Standalone. 这可以达到目的,但实际上是启动了Standalone Standalone。 It seems to work fine (it is not a big or complicated app at all, maybe a few users at a time). 它似乎运行良好(它根本不是一个大应用程序,也不是一个复杂的应用程序,一次可能只有几个用户)。 I can navigate back to my directory and start and stop it using the above command (and passenger stop -p 80). 我可以导航到我的目录,并使用上述命令(和passenger stop -p 80)启动和停止它。

However, now my capistrano deploy (cap deploy) no longer restarts the server on a deploy (it is trying to run touch tmp/restart.txt) - which even if I try to run manually, does nothing since the server is running Passenger Standalone. 但是,现在我的capistrano部署(cap deploy)不再在部署上重新启动服务器(它正在尝试运行touch tmp / restart.txt)-即使我尝试手动运行,由于服务器正在运行Passenger Standalone,因此即使我尝试手动运行也不起作用。

I can't remember how I got the server up and running in the first place because it was so long ago. 我不记得最初是如何启动和运行服务器的,因为它已经很久了。 I'm not using RVM - just the version of Ruby running directly on the server. 我没有使用RVM,而是直接在服务器上运行的Ruby版本。

Does anyone know the correct command to start nginx/passenger (not standalone) on Ubuntu? 有谁知道在Ubuntu上启动nginx / passenger(不是独立的)的正确命令?

And even a step further - how I can get mysqld and nginx/passenger to automatically load on a hard server restart? 甚至更进一步-如何使mysqld和nginx / passenger自动在硬服务器重启时加载?

Capistrano does not restart the server because it actually creates a new app directory (/u/apps/.../releases/xxx), while Passenger Standalone is still running in the old app directory (/u/apps/.../releases/yyy). Capistrano不会重新启动服务器,因为它实际上创建了一个新的应用程序目录(/u/apps/.../releases/xxx),而Passenger Standalone仍在旧的应用程序目录中运行(/u/apps/.../发布/ yyy)。 Therefore touching restart.txt doesn't work. 因此,触摸restart.txt不起作用。 Instead, you have to restart Passenger Standalone like this: 相反,您必须像这样重新启动“乘客独立”:

cd /path-to-previous-release && passenger stop -p 80
cd /path-to-current-release && passenger start -p 80 -e production

You mentioned you want to start nginx/passsenger. 您提到要启动nginx / passsenger。 I assume that you mean the Nginx mode . 我认为您的意思是Nginx模式 Here's what you need to do: 这是您需要做的:

  1. Install Phusion Passenger using the official Passenger APT repository . 使用官方的APT乘客库安装Phusion乘客。
  2. There is no step 2. If you did step 1, then the Ubuntu package will automatically configure Nginx to start at system boot, which will automatically start Passenger as well. 没有步骤2。如果执行了步骤1,则Ubuntu软件包将自动将Nginx配置为在系统启动时启动,这也会自动启动Passenger。

I don't understand why you ask how you can get mysqld to automatically start on a hard server restart. 我不明白为什么您问您如何使mysqld在硬服务器重启时自动启动。 Mysqld is always started during system boot. Mysqld 始终在系统引导期间启动。 You don't have to do anything. 您不必做任何事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM