简体   繁体   English

Gulp任务未在弹性beantalk上运行

[英]Gulp tasks not running on elastic beanstalk

I have a question regarding the aws elastic beanstalk service and gulp. 我对aws弹性beanstalk服务和gulp有疑问。 I am very new in both gulp and elastic beanstalk so sorry of it is a dumb question... 我在吞咽和有弹性的豆茎上都非常新,所以对不起这是一个愚蠢的问题...

I've created a gulp file on the root server folder: 我已经在根服务器文件夹上创建了一个gulp文件:

var gulp = require('gulp'),
    concat = require('gulp-concat'),
    uglify = require('gulp-uglify');


gulp.task('scripts', function() {
    return gulp.src(['public/**/*.js'])
        .pipe(concat('scripts.js'))
        .pipe(gulp.dest('public/js'))
        .pipe(uglify(""))
        .pipe(gulp.dest('public/js'));
});

gulp.task('default', ['scripts'], function(){});

And a package.json file that contains all the dependencies and the scripts object: 还有一个package.json文件,其中包含所有依赖项和脚本对象:

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "gulp": "gulp",
    "start": "npm run gulp && node server.js"
},

But when I deploy the application to elastic elastic beanstalk it seems like the server is not running the gulp tasks (the file 'public/js/scripts.js' is not found on the server). 但是,当我将应用程序部署到具有弹性的beantalk上时,似乎服务器未在运行gulp任务(在服务器上找不到文件“ public / js / scripts.js”)。

As requested these are the last 100 logs from the server (the only section that seems relevant): 根据要求,这些是服务器上的最后100条日志(似乎唯一相关的部分):

-------------------------------------
/var/log/eb-activity.log
-------------------------------------
  decamelize@1.0.0 /tmp/deployment/application/node_modules/gulp-uglify/node_modules/uglify-js/node_modules/yargs/node_modules/decamelize
  window-size@0.1.0 /tmp/deployment/application/node_modules/gulp-uglify/node_modules/uglify-js/node_modules/yargs/node_modules/window-size
  wordwrap@0.0.2 /tmp/deployment/application/node_modules/gulp-uglify/node_modules/uglify-js/node_modules/yargs/node_modules/wordwrap
  uglify-to-browserify@1.0.2 /tmp/deployment/application/node_modules/gulp-uglify/node_modules/uglify-js/node_modules/uglify-to-browserify
  vinyl-sourcemaps-apply@0.1.4 /tmp/deployment/application/node_modules/gulp-uglify/node_modules/vinyl-sourcemaps-apply
  source-map@0.1.43 /tmp/deployment/application/node_modules/gulp-uglify/node_modules/vinyl-sourcemaps-apply/node_modules/source-map
  amdefine@0.1.0 /tmp/deployment/application/node_modules/gulp-uglify/node_modules/vinyl-sourcemaps-apply/node_modules/source-map/node_modules/amdefine
  Running npm install:  /opt/elasticbeanstalk/node-install/node-v0.10.31-linux-x64/bin/npm
  Running npm with --production flag
[2015-04-24T07:11:29.853Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage0/AppDeployPreHook/60config_generate.sh] : Starting activity...
[2015-04-24T07:11:50.652Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage0/AppDeployPreHook/60config_generate.sh] : Completed activity. Result:
  + /opt/elasticbeanstalk/containerfiles/ebnode.py --action generate-config
  Generating modifications to /etc/nginx/nginx.conf
  Generating reverse proxy settings
[2015-04-24T07:11:50.653Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage0/AppDeployPreHook] : Completed activity. Result:
  Successfully execute directory: /opt/elasticbeanstalk/hooks/appdeploy/pre.
[2015-04-24T07:11:50.653Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage0/EbExtensionPostBuild] : Starting activity...
[2015-04-24T07:11:54.361Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage0/EbExtensionPostBuild] : Completed activity.
[2015-04-24T07:11:54.361Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage0/InfraCleanEbextension] : Starting activity...
[2015-04-24T07:11:54.720Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage0/InfraCleanEbextension] : Completed activity. Result:
  Cleaned ebextensions subdirectories from /tmp/deployment/application.
[2015-04-24T07:11:54.720Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage0] : Completed activity. Result:
  Command CMD-AppDeploy stage 0 completed.
[2015-04-24T07:11:54.721Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage1] : Starting activity...
[2015-04-24T07:11:54.721Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage1/AppDeployEnactHook] : Starting activity...
[2015-04-24T07:11:54.721Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage1/AppDeployEnactHook/10stop.sh] : Starting activity...
[2015-04-24T07:12:09.244Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage1/AppDeployEnactHook/10stop.sh] : Completed activity. Result:
  + /opt/elasticbeanstalk/containerfiles/ebnode.py --action stop-all
  nodejs stop/waiting
  nginx stop/waiting
  status: Unknown job: httpd
  status: Unknown job: httpd
  Job already stopped. Not stopping again.
  Job already stopped. Not stopping again.
  Did not find to find status of init job. Assuming stopped.
  Did not find to find status of init job. Assuming stopped.
[2015-04-24T07:12:09.244Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage1/AppDeployEnactHook/20clean.sh] : Starting activity...
[2015-04-24T07:12:09.490Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage1/AppDeployEnactHook/20clean.sh] : Completed activity. Result:
  ++ /opt/elasticbeanstalk/bin/get-config container -k app_base_dir
  + EB_APP_BASE_DIR=/var/app
  + rm -rf /var/app
[2015-04-24T07:12:09.490Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage1/AppDeployEnactHook/30app_deploy.sh] : Starting activity...
[2015-04-24T07:12:10.259Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage1/AppDeployEnactHook/30app_deploy.sh] : Completed activity. Result:
  ++ /opt/elasticbeanstalk/bin/get-config container -k app_base_dir
  + EB_APP_BASE_DIR=/var/app
  ++ /opt/elasticbeanstalk/bin/get-config container -k app_staging_dir
  + EB_APP_STAGING_DIR=/tmp/deployment/application
  ++ /opt/elasticbeanstalk/bin/get-config container -k app_deploy_dir
  + EB_APP_DEPLOY_DIR=/var/app/current
  ++ /opt/elasticbeanstalk/bin/get-config container -k app_user
  + EB_APP_USER=nodejs
  + mkdir /var/app
  + mv /tmp/deployment/application /var/app/current
  + chown -R nodejs:nodejs /var/app/current
[2015-04-24T07:12:10.259Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage1/AppDeployEnactHook/40config_deploy.sh] : Starting activity...
[2015-04-24T07:12:10.477Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage1/AppDeployEnactHook/40config_deploy.sh] : Completed activity. Result:
  ++ /opt/elasticbeanstalk/bin/get-config container -k config_staging_dir
  + EB_CONFIG_STAGING_DIR=/tmp/deployment/config
  ++ ls /tmp/deployment/config
  + for i in '$(ls $EB_CONFIG_STAGING_DIR)'
  ++ sed -e 's/#/\//g'
  ++ echo '#etc#init#nginx.conf'
  + FILE_NAME=/etc/init/nginx.conf
  + /bin/cp /tmp/deployment/config/#etc#init#nginx.conf /etc/init/nginx.conf
  + for i in '$(ls $EB_CONFIG_STAGING_DIR)'
  ++ sed -e 's/#/\//g'
  ++ echo '#etc#init#nodejs.conf'
  + FILE_NAME=/etc/init/nodejs.conf
  + /bin/cp /tmp/deployment/config/#etc#init#nodejs.conf /etc/init/nodejs.conf
  + for i in '$(ls $EB_CONFIG_STAGING_DIR)'
  ++ sed -e 's/#/\//g'
  ++ echo '#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf'
  + FILE_NAME=/etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
  + /bin/cp /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
  + for i in '$(ls $EB_CONFIG_STAGING_DIR)'
  ++ sed -e 's/#/\//g'
  ++ echo '#etc#nginx#nginx.conf'
  + FILE_NAME=/etc/nginx/nginx.conf
  + /bin/cp /tmp/deployment/config/#etc#nginx#nginx.conf /etc/nginx/nginx.conf
[2015-04-24T07:12:10.478Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage1/AppDeployEnactHook/50start.sh] : Starting activity...
[2015-04-24T07:12:13.171Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage1/AppDeployEnactHook/50start.sh] : Completed activity. Result:
  + /opt/elasticbeanstalk/containerfiles/ebnode.py --action start-all
  nodejs start/running, process 7307
  nginx start/running, process 7316
[2015-04-24T07:12:13.171Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage1/AppDeployEnactHook] : Completed activity. Result:
  Successfully execute directory: /opt/elasticbeanstalk/hooks/appdeploy/enact.
[2015-04-24T07:12:13.171Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage1/AppDeployPostHook] : Starting activity...
[2015-04-24T07:12:13.172Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage1/AppDeployPostHook] : Completed activity. Result:
  Successfully execute directory: /opt/elasticbeanstalk/hooks/appdeploy/post.
[2015-04-24T07:12:13.172Z] INFO  [6756]  - [CMD-AppDeploy/AppDeployStage1] : Completed activity. Result:
  Command CMD-AppDeploy stage 1 completed.
[2015-04-24T07:12:13.172Z] INFO  [6756]  - [CMD-AppDeploy/AddonsAfter] : Starting activity...
[2015-04-24T07:12:13.172Z] INFO  [6756]  - [CMD-AppDeploy/AddonsAfter] : Completed activity.
[2015-04-24T07:12:13.172Z] INFO  [6756]  - [CMD-AppDeploy] : Completed activity. Result:
  Command CMD-AppDeploy succeeded.
[2015-04-24T07:12:42.655Z] INFO  [7329]  - [CMD-TailLogs] : Starting activity...
[2015-04-24T07:12:43.083Z] INFO  [7329]  - [CMD-TailLogs/AddonsBefore] : Starting activity...
[2015-04-24T07:12:43.083Z] INFO  [7329]  - [CMD-TailLogs/AddonsBefore] : Completed activity.
[2015-04-24T07:12:43.083Z] INFO  [7329]  - [CMD-TailLogs/TailLogs] : Starting activity...
[2015-04-24T07:12:43.084Z] INFO  [7329]  - [CMD-TailLogs/TailLogs/TailLogs] : Starting activity...

What did I do wrong? 我做错了什么? Thanks 谢谢

You should provide the log of what happens after Elastic Beanstalk tries to run npm start . 您应该提供在Elastic Beanstalk尝试运行npm start之后发生的情况的日志。 You can get this from the command line or the Console by going to Logs > Request Logs > Last 100 Lines . 您可以通过在命令行或控制台得到这个Logs > Request Logs > Last 100 Lines

Going off what you've posted, I'm going to assume that the issue is that you don't have Gulp installed at the global level. 从您发布的内容开始,我将假设问题是您没有在全局级别安装Gulp。 By running gulp , it is going to look in your bin for that executable. 通过运行gulp ,它将在您的bin中查找该可执行文件。 That executable won't be there even if you have gulp in your package.json since the package.json only installs it locally. 即使package.jsongulp ,该可执行文件也不会存在,因为package.json仅在本地安装。

What if you were to run npm install -g gulp before the start command? 如果要在start命令之前运行npm install -g gulp怎么办? You could do this in the start command or use any of NPM's "scripts" . 您可以在start命令中执行此操作,也可以使用NPM的任何“脚本” preinstall might be the one to use. preinstall可能是使用的一种。 It would look like this: 它看起来像这样:

"scripts": {
  "test": "echo \"Error: no test specified\" && exit 1",
  "gulp": "gulp",
  "preinstall": "npm install -g gulp",
  "prestart": "npm run gulp",
  "start": "node server.js"
},

I've also moved npm run gulp to the prestart script since it should be ran before running start. 我还将npm run gulp移到了prestart脚本中,因为它应该在运行start之前运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM