npm global install on elastic beanstalk

Jef*_*f W 9 amazon-web-services node.js npm amazon-elb amazon-elastic-beanstalk

我遇到了在aws弹性beanstalk上全局安装pm2的问题.我创建了以下用于安装pm2的脚本:

option_settings:
  - option_name: NODE_ENV
    value: production
container_commands:
  01_enable_rootaccess:
    command: echo Defaults:root \!requiretty >> /etc/sudoers 
  02_install_imagemagic:
    command: yum install -y ImageMagick
  03_download_new_relic:
    command: rpm -Uvh http://download.newrelic.com/pub/newrelic/el5/i386/newrelic-repo-5-3.noarch.rpm 
    ignoreErrors: true
  04_install_new_relic:
    command: yum install -y newrelic-sysmond
    ignoreErrors: true
  05_add_license_key:
    command: /usr/sbin/nrsysmond-config --set license_key=xxxxxxx
    ignoreErrors: true
  06_start_new_relic:
    command: /etc/init.d/newrelic-sysmond start
    ignoreErrors: true
  07_install_pm2:
    command: sudo /opt/elasticbeanstalk/node-install/node-v0.10.26-linux-x64/bin/npm install pm2 -g
    ignoreErrors: true    
  08_stop_old_pm2_processes:
    command: sudo /opt/elasticbeanstalk/node-install/node-v0.10.26-linux-x64/bin/pm2 delete all
    ignoreErrors: true
  09_start_pm2:
    command: sudo /opt/elasticbeanstalk/node-install/node-v0.10.26-linux-x64/bin/pm2 startup -u ec2-user
    ignoreErrors: true
Run Code Online (Sandbox Code Playgroud)

我已经尝试使用'pm2 delete all'和'pm2 startup'来执行命令8和9 put i just get command not found.当我给pm2的具体路径(我登录到ec2并验证)时,我得到"第4行:exec :: not found".知道我在这里做错了什么吗?在此先感谢您的帮助!

asa*_* am 6

我设法在弹性beanstalk上全局安装pm2,并在.ebextensions/your_file_name.config文件中嵌入了以下代码片段

container_commands:
  01_node_symlink:
    command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/node /bin/node"
  02_npm_symlink:
    command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/npm /bin/npm"
  03_pm2_install:
    command: "if [ ! -e /bin/pm2 ]; then npm install pm2 -g; fi"
    ignoreErrors: true
Run Code Online (Sandbox Code Playgroud)


Sam*_*kes 0

您可能需要确保该nodejs-legacy模块已安装。如果pm2取决于名为 的可执行文件node,那么当系统像nodejs某些 Linux 系统(Ubuntu、Debian)经常那样全局安装它时,就会失败。