2017-06-10 66 views
0

此錯誤AWS codedeploy拋出錯誤缺少腳本:停止

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 

感謝

回答

-2

您需要通過將腳本添加到package.json文件來告訴npm該做什麼。有關文檔,請參閱https://docs.npmjs.com/misc/scripts

+0

您應該提供有關如何操作的說明。 –

+0

爲了在package.json中指定腳本,添加了npm文檔的鏈接。 – tangerini

+2

鼓勵與外部資源的鏈接,但請在鏈接上添加上下文,以便您的同行用戶瞭解它是什麼以及它爲什麼在那裏。如果目標網站無法訪問或永久離線,請始終引用重要鏈接中最相關的部分。看[如何寫出一個好的答案](https://stackoverflow.com/help/how-to-answer) –