执行命令后,部署AWS魔豆魔豆、命令、AWS

2023-09-11 11:48:06 作者:空中鹰

我有问题,部署后执行的命令,我有一些Node.js的项目和脚本,该脚本使用一些斌从node_modules,如果我写我的命令,在.ebextensions /的.config脚本,他执行NPM安装前和返回错误(node_modules /的.bin /一些:没有这样的文件或目录)。我怎么能部署后执行的命令。谢谢你。

I have problem with execute command after deploy, i have some node.js project and script, this script use some bin from node_modules, if i write my command for script in .ebextensions/.config he execute before npm install and return error ("node_modules/.bin/some": No such file or directory). How i can execute command after deploy. Thanks.

推荐答案

我发现了以下解决方案

我添加到青苗配置下一个命令:

I add to beanstalk config next command:

commands:
  create_post_dir:
    command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post"
    ignoreErrors: true
files:
  "/opt/elasticbeanstalk/hooks/appdeploy/post/some_job.sh":
    mode: "000755"
    owner: root
    group: root
    content: |
      #!/usr/bin/env bash
      /var/app/current
      npm run some_script

此命令创建(如果不存在)的文件夹后钩子脚本,并增加了bash脚本。在此文件夹中的脚本只执行后NPM安装,这个非常重要的,我的问题。

This commands create(if not exist) folder for post-hooks scripts and adds bash script. Scripts in this folders execute only after npm install, this very important for my problem.

感谢这家伙的http://junkheap.net/blog/2013/05/20/elastic-beanstalk-post-deployment-scripts/