如何从google计算引擎连接到rails控制台

时间:2023-01-16 09:48:21

I have deployed a rails 4.2 app to googles cloud platform using runtime ruby. I have an instance running in googles compute engine that I can SSH onto but I cant locate the apps directory so I can run rails console and get the console going.

我已经部署了一个rails 4.2应用程序,使用运行时ruby来使用google云平台。我有一个运行在google计算引擎中的实例,我可以SSH到它,但是我不能找到应用程序目录,这样我就可以运行rails控制台并启动控制台。

How can I run the rials console on the compute engine instance? As far as I can get is running sudo suin the instance and then all directories in there just seem to have dead ends, none lead to the project I deployed.

如何在compute engine实例上运行rials控制台?就我所能得到的,是在实例中运行sudo suin,然后那里的所有目录似乎都有死角,没有一个指向我部署的项目。

1 个解决方案

#1


2  

The instance that you log into will be running your code in a docker container. Try this;

您登录的实例将在docker容器中运行代码。试试这个;

List all the containers that are running:

列出所有正在运行的容器:

sudo docker ps 

Find the container that is running your code (look at the command column, it might start with bundle exec etc)

找到运行代码的容器(查看命令列,它可能以bundle exec开始)

Start a bash shell on the app container

在应用程序容器上启动bash shell

container_exec your-app-container-id /bin/bash

Once you're in a bash shell of your container, your code will be in /app

在容器的bash shell中,代码将在/应用程序中。

cd /app

If you need to execute a rails console, you'll need to add the right bin folders to your path

如果需要执行rails控制台,则需要将正确的bin文件夹添加到路径中

export PATH=$PATH:/rbenv/versions/2.3.4/bin:/rbenv/bin:/nodejs/bin
cd /app && bundle exec rails c production

#1


2  

The instance that you log into will be running your code in a docker container. Try this;

您登录的实例将在docker容器中运行代码。试试这个;

List all the containers that are running:

列出所有正在运行的容器:

sudo docker ps 

Find the container that is running your code (look at the command column, it might start with bundle exec etc)

找到运行代码的容器(查看命令列,它可能以bundle exec开始)

Start a bash shell on the app container

在应用程序容器上启动bash shell

container_exec your-app-container-id /bin/bash

Once you're in a bash shell of your container, your code will be in /app

在容器的bash shell中,代码将在/应用程序中。

cd /app

If you need to execute a rails console, you'll need to add the right bin folders to your path

如果需要执行rails控制台,则需要将正确的bin文件夹添加到路径中

export PATH=$PATH:/rbenv/versions/2.3.4/bin:/rbenv/bin:/nodejs/bin
cd /app && bundle exec rails c production