如何从Google计算引擎连接到Rails控制台 [英] How do I connect to the rails console from googles compute engine

查看:153
本文介绍了如何从Google计算引擎连接到Rails控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用运行时ruby部署了一个rails 4.2应用程序来Google云平台。我有一个运行在谷歌计算引擎中的实例,我可以通过SSH进入,但无法找到apps目录,因此我可以运行 rails console 并让控制台继续运行。



如何在计算引擎实例上运行 rials控制台?据我所知,在该实例中运行 sudo su ,然后所有的目录似乎都有死角,但没有一个导致我部署的项目。

解决方案

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

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

pre $

sudo docker ps

找到正在运行代码的容器(查看命令列,它可能会启动使用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 suin 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆