简体   繁体   English

无法在生产服务器上启动rails 4控制台

[英]Cannot start rails 4 console on production server

Having a weird issue and need help. 有一个奇怪的问题,需要帮助。

I am trying to start a rails console on a production server and it is acting like the rails c command does not exist. 我正在尝试在生产服务器上启动rails控制台,它的行为类似于rails c命令不存在。

FWIW, I have been a rails developer for 4 years and do this all the time on a plethora of other servers without issue. FWIW,我已经成为一名铁路开发人员已有4年,并且一直在很多其他服务器上这样做而没有问题。 On this server, I can drop, create, migrate, seed the database with no problems (using RAILS_ENV=production), and the app works fine live without any issues. 在这台服务器上,我可以毫无问题地删除,创建,迁移,播种数据库(使用RAILS_ENV =生产),并且应用程序可以正常运行而不会出现任何问题。

Setup: 建立:

Ubuntu 14.04 (racksapce 2nd gen performance 1 server) Ubuntu 14.04(racksapce第二代性能1服务器)
Nginx with Passenger (I typically use Unicorn, but have never had a problem on any of the apps I have deployed with Passenger) 带乘客的Nginx(我通常使用Unicorn,但我在使用Passenger部署的任何应用程序上从未出现过问题)
Ruby 2.1.5 (using rvm) Ruby 2.1.5(使用rvm)
Rails 4.1.7 Rails 4.1.7
Postgres Postgres的
Capistrano 3 (using the rvm, migrations, asset-precompilation, etc. extensions) Capistrano 3(使用rvm,迁移,资产预编译等扩展)

What I've tried: 我尝试过的:

cd into app directory: 进入app目录:

cd /home/deployer/app_name/current

Which loads .rvmrc and shows that I am in the correct gemset, ran bundle just for kicks. 哪个加载.rvmrc并显示我在正确的gemset中,运行bundle只是为了踢。

rails c production # (which usually works no problem)

bundle exec rails c production # (sometimes have to do this on older apps that do not have the newer capistrano 3 and rvm setup)

rails c production RAILS_ENV=production # (getting desperate here)

RAILS_ENV=production rails c production # (haha, surely this won't work, but out of options)

RAILS_ENV=production bundle exec rails console

Every time, I get a notice that implies 'rails c' is not a valid command: 每次,我都会收到一条暗示'rails c'不是有效命令的通知:

Usage:
  rails new APP_PATH [options]

Options:
  -r, [--ruby=PATH]                                      # Path to the Ruby binary     of your choice

..... yada yada, shows the rest of the rails options (oddly enough does not show 'c' or 'console' as options?)

Again, I have logged into hundreds of production consoles on both nginx/apache deployed with old and new versions of both Unicorn and mostly older versions of Passenger. 同样,我已经在nginx / apache上登录了数百个生产控制台,这些控制台部署了Unicorn的旧版本和新版本以及大多数旧版本的Passenger。

This is the first time I have ever gotten this message, and the console is the ONLY thing that seems to be broken - everything else works fine! 这是我第一次收到这条消息,而控制台是唯一似乎被打破的东西 - 其他一切正常! the app is live and works great. 该应用程序是实时的,工作得很好。

I know that the first thing to be suggested is that I am not running rails c production from the app directory - I have cd'd into the correct directory at least 10 times and manually loaded the correct gemset, this is not the issue. 我知道首先要建议的是我没有从app目录运行rails c production - 我已经cd到正确的目录中至少10次并手动加载了正确的gemset,这不是问题。

Can't figure out why it works fine in development, but not in production. 无法弄清楚为什么它在开发中工作得很好,但在生产中却没有。 I know there used to be a scripts directory a while back (maybe rails 2?)- Is there still a directory that contains the script commands for rails that may have been corrupted? 我知道曾经有一个脚本目录(可能是rails 2?) - 是否还有一个包含可能已损坏的rails的脚本命令的目录?

Has anyone ever experienced this before or have any suggestions? 有没有人曾经经历过这个或有任何建议?

I feel like I am missing something. 我觉得我错过了什么。

Ok, found the issue... @stoodfarback was pretty close, but I thought the cause of the issue needed to be mentioned for others who might encounter the same thing. 好的,发现问题... @stoodfarback非常接近,但我认为需要为可能遇到同样事情的其他人提及问题的原因。

Basically I am using a newer version of Capistrano (3.3.5) than I have used in the past and it (by default) adds 'bin' to the list of shared directories that it symlinks on each deploy. 基本上我使用的是比我过去使用的更新版本的Capistrano(3.3.5),它(默认情况下)将'bin'添加到每个部署上符号链接的共享目录列表中。

set :linked_dirs, fetch(:linked_dirs, []).push('bin', 'log', 'tmp', 'public/system', "public/downloads", "public/assets")

So the deploy script created a new directory in shared called bin (which was empty) and the files used to launch rails server and console were missing. 因此,部署脚本在共享的bin中创建了一个新目录(它是空的),并且缺少用于启动rails服务器和控制台的文件。 They were obviously still there in development, so it only affected production. 它们显然仍处于开发阶段,因此它只会影响生产。

Removed 'bin' from the linked_dirs list and everything now works as expected. 从linked_dirs列表中删除了'bin',现在一切都按预期工作了。

now looks like: 现在看起来像:

set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp', 'public/system', "public/downloads","publ ic/assets")

I have noticed on the last few versions of Capistrano that I have used, the format and defaults for linked_dirs keeps changing quite a bit, but I had never seen bin in that list. 我已经注意到我使用的最后几个版本的Capistrano,linked_dirs的格式和默认值一直在变化,但我从未在列表中看到过bin。 Not really sure why bin would need to be symlinked... it only has the default rails files and I can't think of why they would need to be removed from source control, but maybe the Capistrano team has a reason. 不确定为什么bin需要符号链接...它只有默认的rails文件,我想不出为什么需要从源代码控制中删除它们,但也许Capistrano团队有理由。

Hope this helps someone. 希望这有助于某人。

检查您是否有这些文件并尝试删除它们:

  • script/rails
  • bin/rails

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

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