使用capistrano上传ruby on rails应用程序时出现错误



我试图上传我的应用程序创建在ruby on rails与capistrano遵循本指南,但在做"帽生产部署"的时刻,它显示了我以下错误:

00:34 passenger:restart
01 passenger-config restart-app /home/deploy/myapp --ignore-app-not-running
01 *** ERROR: Phusion Passenger(R) doesn't seem to be running. If you are sure that it
01 is running, then the causes of this problem could be one of:
01
01  1. You customized the instance registry directory using Apache's
01     PassengerInstanceRegistryDir option, Nginx's
01     passenger_instance_registry_dir option, or Phusion Passenger(R) Standalone's
01     --instance-registry-dir command line argument. If so, please set the
01     environment variable PASSENGER_INSTANCE_REGISTRY_DIR to that directory
01     and run this command again.
01  2. The instance directory has been removed by an operating system background
01     service. Please set a different instance registry directory using Apache's
01     PassengerInstanceRegistryDir option, Nginx's passenger_instance_registry_dir
01     option, or Phusion Passenger(R) Standalone's --instance-registry-dir command
01     line argument.
(Backtrace restricted to imported tasks)
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing as deploy@54.333.12.94: passenger-config exit status: 1
passenger-config stdout: Nothing written
passenger-config stderr: *** ERROR: Phusion Passenger(R) doesn't seem to be running. If you are sure that it
is running, then the causes of this problem could be one of:

1. You customized the instance registry directory using Apache's
PassengerInstanceRegistryDir option, Nginx's
passenger_instance_registry_dir option, or Phusion Passenger(R) Standalone's
--instance-registry-dir command line argument. If so, please set the
environment variable PASSENGER_INSTANCE_REGISTRY_DIR to that directory
and run this command again.
2. The instance directory has been removed by an operating system background
service. Please set a different instance registry directory using Apache's
PassengerInstanceRegistryDir option, Nginx's passenger_instance_registry_dir
option, or Phusion Passenger(R) Standalone's --instance-registry-dir command
line argument.


Caused by:
SSHKit::Command::Failed: passenger-config exit status: 1
passenger-config stdout: Nothing written
passenger-config stderr: *** ERROR: Phusion Passenger(R) doesn't seem to be running. If you are sure that it
is running, then the causes of this problem could be one of:

1. You customized the instance registry directory using Apache's
PassengerInstanceRegistryDir option, Nginx's
passenger_instance_registry_dir option, or Phusion Passenger(R) Standalone's
--instance-registry-dir command line argument. If so, please set the
environment variable PASSENGER_INSTANCE_REGISTRY_DIR to that directory
and run this command again.
2. The instance directory has been removed by an operating system background
service. Please set a different instance registry directory using Apache's
PassengerInstanceRegistryDir option, Nginx's passenger_instance_registry_dir
option, or Phusion Passenger(R) Standalone's --instance-registry-dir command
line argument.

Tasks: TOP => passenger:restart
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as deploy@54.333.12.94: passenger-config exit status: 1
passenger-config stdout: Nothing written
passenger-config stderr: *** ERROR: Phusion Passenger(R) doesn't seem to be running. If you are sure that it
is running, then the causes of this problem could be one of:

1. You customized the instance registry directory using Apache's
PassengerInstanceRegistryDir option, Nginx's
passenger_instance_registry_dir option, or Phusion Passenger(R) Standalone's
--instance-registry-dir command line argument. If so, please set the
environment variable PASSENGER_INSTANCE_REGISTRY_DIR to that directory
and run this command again.
2. The instance directory has been removed by an operating system background
service. Please set a different instance registry directory using Apache's
PassengerInstanceRegistryDir option, Nginx's passenger_instance_registry_dir
option, or Phusion Passenger(R) Standalone's --instance-registry-dir command
line argument.


** DEPLOY FAILED
** Refer to log/capistrano.log for details. Here are the last 20 lines:


DEBUG [839db3b4] Running /usr/bin/env passenger -v as deploy@54.333.12.94

DEBUG [839db3b4] Command: cd /home/deploy && ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="3.1.2" ; /usr/bin/env passenger -v )

DEBUG [839db3b4]   Phusion Passenger(R) 6.0.14

DEBUG [839db3b4] Finished in 0.586 seconds with exit status 0 (successful).

INFO [82583b63] Running /usr/bin/env passenger-config restart-app /home/deploy/myapp --ignore-app-not-running as deploy@54.333.12.94

DEBUG [82583b63] Command: cd /home/deploy && ( export RBENV_ROOT="$HOME/.rbenv" RBENV_VERSION="3.1.2" ; /usr/bin/env passenger-config restart-app /home/deploy/myapp --ignore-app-not-running )

DEBUG [82583b63]   *** ERROR: Phusion Passenger(R) doesn't seem to be running. If you are sure that it

DEBUG [82583b63]   is running, then the causes of this problem could be one of:

DEBUG [82583b63]   

DEBUG [82583b63]    1. You customized the instance registry directory using Apache's

DEBUG [82583b63]       PassengerInstanceRegistryDir option, Nginx's

DEBUG [82583b63]       passenger_instance_registry_dir option, or Phusion Passenger(R) Standalone's

DEBUG [82583b63]       --instance-registry-dir command line argument. If so, please set the

DEBUG [82583b63]       environment variable PASSENGER_INSTANCE_REGISTRY_DIR to that directory

DEBUG [82583b63]       and run this command again.

DEBUG [82583b63]    2. The instance directory has been removed by an operating system background

DEBUG [82583b63]       service. Please set a different instance registry directory using Apache's

DEBUG [82583b63]       PassengerInstanceRegistryDir option, Nginx's passenger_instance_registry_dir

DEBUG [82583b63]       option, or Phusion Passenger(R) Standalone's --instance-registry-dir command

DEBUG [82583b63]       line argument.

是什么bug导致的?

我的rails应用程序很简单,是用ruby 3.1.2和rails 7.0.3开发的

我正在AWS上上传应用程序,并且我已经添加了secret_base_key。当我安装nginx和修改文件/etc/nginx/sites-enabled/myapp与出现在指南中的内容并重新启动时,它没有引起任何错误,但现在如果我试图重新启动它,它告诉我以下内容:

nginx。服务未激活,无法重新加载。

我在使用Apache而不是Nginx时遇到了类似的问题,但我相信解决方案仍然适用。

在您的服务器上,创建以下目录:

mkdir /var/run/passenger-instreg

告诉Apache(或Nginx)使用这个路径:

# Nginx
# Add this line into: 
# /etc/nginx/conf.d/mod-http-passenger.conf
passenger_instance_registry_dir /var/run/passenger-instreg;
# Apache
# Add this line into: 
# /etc/apache2/mods-enabled/passenger.conf
PassengerInstanceRegistryDir /var/run/passenger-instreg

然后告诉Capistrano也使用此路径进行客运重启:

# config/deploy.rb
set :passenger_environment_variables, {
'PASSENGER_INSTANCE_REGISTRY_DIR' => '/var/run/passenger-instreg'
}

就是这样!

问题是由Systemd的PrivateTmp引起的。它创造了一个"私人"/tmp目录在每次重新启动时都会更改,因此Passenger不知道在哪里找到该实例注册表。对于Apache,您将在如下路径中找到它:

/tmp/systemd-private-xxxx-apache2.service-xxxx/tmp/passenger.xxxx/

你可以通过在服务文件中设置PrivateTmp=false来禁用它,但你最终会得到非私有的/tmp。

第一个解决方案看起来更干净。

相关内容

  • 没有找到相关文章

最新更新