【问题标题】:Issue with elixir-phoenix-on-google-compute-engineelixir-phoenix-on-google-compute-engine 的问题
【发布时间】:2019-02-26 02:46:27
【问题描述】:

我正在尝试按照本教程部署到 GCP Compute Engine https://cloud.google.com/community/tutorials/elixir-phoenix-on-google-compute-engine

创建防火墙规则后无法连接到提供的外部 IP 遵循本教程没有错误。但创建防火墙规则后无法连接到http://${external_ip}:8080

构建版本已在 Google Cloud Storage 中

我复制hello

gsutil cp _build/prod/rel/hello/bin/hello\
    gs://${BUCKET_NAME}/hello-release

而不是hello.run

gsutil cp _build/prod/rel/hello/bin/hello.run \
    gs://${BUCKET_NAME}/hello-release

我的instance-startup.sh

#!/bin/sh
set -ex
export HOME=/app
mkdir -p ${HOME}
cd ${HOME}

RELEASE_URL=$(curl \
  -s "http://metadata.google.internal/computeMetadata/v1/instance/attributes/release-url" \
  -H "Metadata-Flavor: Google")
gsutil cp ${RELEASE_URL} hello-release
chmod 755 hello-release

wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 \
  -O cloud_sql_proxy
chmod +x cloud_sql_proxy

mkdir /tmp/cloudsql
PROJECT_ID=$(curl \
  -s "http://metadata.google.internal/computeMetadata/v1/project/project-id" \
  -H "Metadata-Flavor: Google")
./cloud_sql_proxy -projects=${PROJECT_ID} -dir=/tmp/cloudsql &

PORT=8080 ./hello-release start

gcloud compute instances get-serial-port-output 显示

...
Feb 23 18:02:35 hello-instance startup-script: INFO startup-script: + PORT=8080 ./hello-release start
Feb 23 18:02:35 hello-instance startup-script: INFO startup-script: + ./cloud_sql_proxy -projects= hello -dir=/tmp/cloudsql
Feb 23 18:02:35 hello-instance startup-script: INFO startup-script: 2019/02/23 18:02:35 Rlimits for file descriptors set to {&{8500 8500}}
Feb 23 18:02:35 hello-instance startup-script: INFO startup-script: ./hello-release: 31: exec: /app/hello_rc_exec.sh: not found
Feb 23 18:02:39 hello-instance startup-script: INFO startup-script: 2019/02/23 18:02:39 Listening on /tmp/cloudsql/hello:asia-east1:hello-db/.s.PGSQL.5432 for hello:asia-east1: hello-db
Feb 23 18:02:39 hello-instance startup-script: INFO startup-script: 2019/02/23 18:02:39 Ready for new connections
Feb 23 18:08:08 hello-instance ntpd[656]: kernel reports TIME_ERROR: 0x41: Clock Unsynchronized

hello_rc_exec.sh 在 Distillery 初始化后生成。它存储在_build/prod/rel/hello/bin/hello_rc_exec.sh

firewall rules

NAME                     NETWORK  DIRECTION  PRIORITY  ALLOW        DENY  DISABLED
default-allow-http-8080  default  INGRESS    1000      tcp:8080           False
...

我也在ps aux | grep erl的实例中运行

hello_team@hello-instance:~$ ps aux | grep erl
hello_t+ 23166  0.0  0.0  12784  1032 pts/0    S+   08:04   0:00 grep erl

我不确定需要什么信息来解决这个问题

请务必询问信息,我会提供。 谢谢

【问题讨论】:

  • Enable billing for your project. -- 不,谢谢。
  • @7stud 哈哈哈。他们免费为您提供 1 年 300 美元。因此,您可以使用它进行开发或尝试一下
  • 您必须提供信用卡或银行详细信息才能设置帐单帐户以验证您的身份... -- 免费试用,为什么他们需要知道谁我是? :(
  • @7stud 我不知道。 AWS 也是如此。以前 AWS 没有要求提供信用卡详细信息。但是现在,在注册时,您需要包含信用卡详细信息。我猜是因为人们在收到账单并创建新帐户后停止付款?哈哈哈
  • 我不太清楚你想解决哪个问题,你能清楚地说明你的问题吗?

标签: google-cloud-platform elixir google-compute-engine phoenix-framework


【解决方案1】:

为了后代,这里是解决方案 (worked out in this forum thread)。

首先,发布者已将 hello 文件而不是 hello.run 上传到云存储。本教程特意指定上传hello.run,因为它是整个版本的完整可执行存档,而hello 只是一个包装脚本,本身无法执行应用程序。因此,需要恢复对程序的这种修改。

其次,海报的应用程序包含elixir_bcrypt 库。该库包含一个 NIF,其平台特定的二进制代码构建在 deps 目录(而不是 _build 目录)中。本教程的过程在交叉编译部署之前没有正确清除 deps 中的二进制文件,因此发布者的 macOS 构建的 bcrypt 库泄漏到构建中。当部署到 Debian 上的计算引擎时,这会在初始化时崩溃。发帖者通过删除deps 目录并在交叉编译时重新安装依赖项来解决此问题。

在讨论中还指出,在进行 Docker 交叉编译时,该教程提倡将用户的应用程序挂载到卷中的不良做法。相反,它应该简单地将应用程序复制到映像中,在那里执行整个构建,然后使用docker cp 来提取构建的工件。这种做法本来可以防止这个问题。已提交work item 以相应地修改教程。

【讨论】:

    【解决方案2】:

    解决方案是here

    感谢大家的帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-25
      • 2015-08-11
      • 1970-01-01
      • 2015-11-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多