AWS codedeploy抛出错误缺少脚本:停止

时间:2017-06-10 21:27:27

标签: node.js amazon-web-services aws-code-deploy

这是错误

Error CodeScriptFailed
Script Namescripts/stop.sh
MessageScript at specified location: scripts/stop.sh run as user root failed with exit code 1
Log TailLifecycleEvent - ApplicationStop
Script - scripts/stop.sh
[stderr]npm ERR! Linux 3.10.42-52.145.amzn1.x86_64
[stderr]npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "stop"
[stderr]npm ERR! node v4.8.3
[stderr]npm ERR! npm  v2.15.11
[stderr]
[stderr]npm ERR! missing script: stop
[stderr]npm ERR! 
[stderr]npm ERR! If you need help, you may report this error at:
[stderr]npm ERR!     <https://github.com/npm/npm/issues>
[stderr]
[stderr]npm ERR! Please include the following file with any support request:
[stderr]npm ERR!     /var/nodejs/CodeDeployDemo/npm-debug.log

这是我的appspec.yml

version 0.0
os: linux
files:
  - source: /
    destination: /var/nodejs/CodeDeployDemo/

hooks:
  BeforeInstall:
    - location: scripts/install.sh
      timeout: 300
      runas: root
  AfterInstall:
    - location: scripts/post_install.sh
      timeout: 600
      runas: root
  ApplicationStart:
    - location: scripts/run.sh
      timeout: 120
      runas: root
  ApplicationStop:
    - location: scripts/stop.sh
      timeout: 120
      runas: root
  ValidateService:
    - location: scripts/validate.sh
      timeout: 60
      runas: root

stop.sh

#!/usr/bin/env
set -e
npm stop /var/nodejs/CodeDeployDemo/index.js

由于

1 个答案:

答案 0 :(得分:-2)

您需要通过将脚本添加到package.json文件来告诉npm要做什么。有关文档,请参阅https://docs.npmjs.com/misc/scripts