gpt4 book ai didi

python - 如何在部署到 Elastic Beanstalk 后运行 Python 脚本

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

我正在尝试在运行 Python 3.4 的 AWS Elastic Beanstalk 64 位 Linux 实例上运行 python 脚本。我目前正在 ebextensions 目录中使用 container_commands 来运行一些命令,但我的问题是这些命令在应用程序完全部署到环境之前运行。有谁知道如何让Python脚本在部署后执行?我发现this older post详细介绍了 Rails 环境的解决方法,但我使用的是 Python。

最佳答案

我想说你有两个选择:

  1. 将脚本托管在 this article 中提到的 appdeploy/post 文件夹中:

So when I was looking at the eb-tools.log on the EC2 instance I found it was searching for scripts to run in a /opt/elasticbeanstalk/hooks/appdeploy/post directory after restarting the web server. Turns out if you drop shell scripts into this directory they will be executed post deployment, just like you want! However this directory does not exist by default, as Amazon does not use any post-deploy scripts, so we also need to make sure this directory is created.

  • 如果第一个选项不起作用,我要做的就是在要部署到该 EB 的代码中添加我想要运行的代码,并将其作为部署过程的一部分运行我正在使用。例如,如果我通过 Windows 计算机上的批处理文件进行部署,我会执行以下操作:

    call eb deploy
    call http://myurl.com/postDeploy
  • 关于python - 如何在部署到 Elastic Beanstalk 后运行 Python 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48696995/

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