如何从Google计算引擎连接到Rails控制台 [英] How do I connect to the rails console from googles compute engine
问题描述
我使用运行时ruby部署了一个rails 4.2应用程序来Google云平台。我有一个运行在谷歌计算引擎中的实例,我可以通过SSH进入,但无法找到apps目录,因此我可以运行 rails console
并让控制台继续运行。
如何在计算引擎实例上运行 rials控制台
?据我所知,在该实例中运行 sudo su
,然后所有的目录似乎都有死角,但没有一个导致我部署的项目。
您登录的实例将在Docker容器中运行您的代码。试试这个;
列出所有正在运行的容器:
pre $
找到正在运行代码的容器(查看命令列,它可能会启动使用bundle exec等)
在app容器上启动一个bash shell
container_exec your-app-container-id / bin / bash
一旦你进入bash shell的容器,你的代码将在/ app中。
cd / app
如果您需要执行rails控制台,则需要将正确的bin文件夹添加到路径中。
export PATH = $ PATH:/rbenv/versions/2.3.4/bin:/ rbenv / bin:/ nodejs / bin
cd / app&& amp ; bundle exec rails c production
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.
How can I run the rials console
on the compute engine instance? As far as I can get is running sudo su
in the instance and then all directories in there just seem to have dead ends, none lead to the project I deployed.
The instance that you log into will be running your code in a docker container. Try this;
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)
Start a bash shell on the app container
container_exec your-app-container-id /bin/bash
Once you're in a bash shell of your container, your code will be in /app
cd /app
If you need to execute a rails console, you'll need to add the right bin folders to your path
export PATH=$PATH:/rbenv/versions/2.3.4/bin:/rbenv/bin:/nodejs/bin
cd /app && bundle exec rails c production
这篇关于如何从Google计算引擎连接到Rails控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!