部署 AWS Beanstalk 后执行命令 [英] Execute command after deploy AWS Beanstalk

查看:24
本文介绍了部署 AWS Beanstalk 后执行命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在部署后执行命令有问题,我有一些 node.js 项目和脚本,这个脚本使用来自 node_modules 的一些 bin,如果我在 .ebextensions/.config 中编写我的脚本命令,他会在 npm install 之前执行并返回错误(node_modules/.bin/some":没有那个文件或目录).部署后如何执行命令.谢谢.

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.

推荐答案

我找到了以下解决方案

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

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
      cd /var/app/current
      export PATH=$PATH:$(ls -td /opt/elasticbeanstalk/node-install/node-* | head -1)/bin
      npm run some_script

此命令为 post-hooks 脚本创建(如果不存在)文件夹并添加 bash 脚本.此文件夹中的脚本仅在 npm install 后执行,这对我的问题非常重要.

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/

这篇关于部署 AWS Beanstalk 后执行命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆