gpt4 book ai didi

amazon-web-services - 从 aws elastic beanstalk 中的 .ebextensions 文件夹运行脚本

转载 作者:行者123 更新时间:2023-12-02 04:04:10 25 4
gpt4 key购买 nike

我试图在 war 上传时运行脚本,所以这里是配置的内容

container_commands:
01_setup_apache:
command: "cp .ebextensions/enable_mod_deflate.conf /etc/httpd/conf.d/enable_mod_deflate.conf"
02_setup_script:
command: "sudo su root"
03_setup_script:
command: "sudo mkdir -p /home/dev"
04_setup_script:
command: "sudo chmod 777 /home/dev -R"
05_setup_script:
command: "sudo cp .ebextensions/scripts/setup.sh /home/dev/"
06_setup_script:
command: "sudo chmod +x /home/dev/setup.sh"
07_setup_script:
command: "sudo /home/dev/setup.sh"
08-restart-apache:
command: "sudo /etc/init.d/httpd restart"

我尝试了所有方法,但部署在执行 setup.sh 时总是失败。在上面的示例中,它在 07_setup_script

上失败

这是日志内容

] : Starting activity...
/Command 01_setup_apache] : Starting activity...
/Command 01_setup_apache] : Completed activity.
/Command 02_setup_script] : Starting activity...
/Command 02_setup_script] : Completed activity.
/Command 03_setup_script] : Starting activity...
/Command 03_setup_script] : Completed activity.
/Command 04_setup_script] : Starting activity...
/Command 04_setup_script] : Completed activity.
/Command 05_setup_script] : Starting activity...
/Command 05_setup_script] : Completed activity.
/Command 06_setup_script] : Starting activity...
/Command 06_setup_script] : Completed activity.
/Command 07_setup_script] : Starting activity...
/Command 07_setup_script] : Activity execution failed, because: sudo: unable to execute /home/dev/setup.sh: No such file or directory
(ElasticBeanstalk::ExternalInvocationError)

如果实例上的 ssh 那里没有文件夹或文件 (/home/dev) 或 (/home/dev/setup.sh),则似乎之前的命令未执行,但日志显示其已完成

我知道有一种方法可以在运行时创建脚本文件,但是我们可以避免这种情况而只使用上面的方法吗?

最佳答案

几个问题。您根本不应该开始尝试管理主目录/目录结构,这绝对超出了 beanstalk 最佳实践。另外,不要以 sudo 身份运行,它会以 root 身份执行钩子(Hook)。

做这样的事情:

.ebextension/foo.config中:

container_commands:
01_restart_httpd:
command: /etc/init.d/httpd restart

files:
/etc/httpd/conf.d/enable_mod_deflate.conf:
mode: "000644"
owner: root
group: root
content: |
#content of your conf

或者也

files:
/etc/httpd/conf.d/enable_mod_deflate.conf:
mode: "000644"
owner: root
group: root
content: |
#content of your conf

/opt/elasticbeanstalk/hooks/appdeploy/post/50_restart_httpd:
mode: "000777"
owner: root
group: root
content: |
#!/bin/sh
/etc/init.d/httpd restart

关于amazon-web-services - 从 aws elastic beanstalk 中的 .ebextensions 文件夹运行脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40357270/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com