amazon-web-services - 运行代码部署挂钩时找不到 Go 命令
问题描述
您好,我正在尝试为我的 golang 应用程序创建 CodeDeploy 部署。我有一个自动缩放组,它使用我创建的 AMI,其中安装了我需要的所有库。当我尝试运行 CodeDeploy 它存在我的错误after_install
:
LifecycleEvent - AfterInstall
Script - scripts/after_install.sh
[stderr]/opt/codedeploy-agent/deployment-root/a65d9a2e-fddd-471c-8ea1-c018792d00bd/d-4IKP3PP4Y/deployment-archive/scripts/after_install.sh:
line 4: go: command not found
我知道 go 已安装在服务器上,我可以通过 ssh 进入服务器并运行 go 命令来验证。最初我让我的after_install
钩子以 root 身份运行,所以这就是为什么我认为它抱怨 go 没有被安装。
我将它更新为运行,因为ubuntu
这里是 appspec 文件
version: 0.0
os: linux
files:
- source: ./
destination: ./home/ubuntu/code
hooks:
AfterInstall:
- location: scripts/after_install.sh
timeout: 180
runas: ubuntu
ApplicationStart:
- location: scripts/application_start.sh
timeout: 180
runas: root
但是我仍然得到 go command not found 的错误。我以用户身份通过 SSH 连接到服务器ubuntu
,我可以清楚地看到 go 已安装。
我更进一步并运行了after_install.sh
文件,它没有错误地工作。我在这里做错了什么?
只是为了特别好奇这里是我的after_install.sh
文件
#!/bin/bash
cd /home/ubuntu/code/vibeify/cmd/vibeify
go build
解决方案
如果您go
只能在交互式 shell 中使用没有完整安装路径的命令,请检查$HOME/.bashrc
.
它可能取决于操作系统默认设置,但某些操作系统默认 bashrc 文件包含不会在非交互式 shell 中加载配置文件的脚本。
# open $HOME/.bashrc file
# and comment out these lines
case $- in
*i*) ;;
*) return;;
esac
推荐阅读
- git - 詹金斯如何创建一些带有推送标签的容器,称为name_v0.01?
- machine-learning - 回到 XOR 问题的基础 - 从根本上混淆
- python - 模型的输出张量必须是模型 Api Tensorfow 中 TensorFlow `Layer` 的输出(因此保存过去的层元数据)
- ionic-framework - Flutterwave 与 Ionic 4 的集成
- html - 如何关闭以前的 EventSource
- c++ - 为什么可以使用指针创建新结构,但不能以相同的方式创建双精度结构?
- java - 导入 Maven 项目后出现 TestNG 错误
- java - Tomcat 不提供简单的 HTML 页面 (HTTP 404)
- spring-boot - 使用 Spring-Config Cloud Server 在自定义文件夹中加载多个基于 Profile 的属性
- r - 在 .rmd 文件中编译 TeX 的错误以创建 .html