简体   繁体   中英

Gulp tasks not running on elastic beanstalk

I have a question regarding the aws elastic beanstalk service and 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:

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:

"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).

As requested these are the last 100 logs from the server (the only section that seems relevant):

-------------------------------------
/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 . You can get this from the command line or the Console by going to 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. By running gulp , it is going to look in your bin for that executable. That executable won't be there even if you have gulp in your package.json since the package.json only installs it locally.

What if you were to run npm install -g gulp before the start command? You could do this in the start command or use any of NPM's "scripts" . preinstall might be the one to use. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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