我有一个关于aws弹性beanstalk服务和gulp的问题。 我在吞咽和弹性豆茎方面都是新手,所以很抱歉这是一个愚蠢的问题......
我在根服务器文件夹上创建了一个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(){});
包含所有依赖项和脚本对象的package.json文件:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"gulp": "gulp",
"start": "npm run gulp && node server.js"
},
但是当我将应用程序部署到弹性弹性beanstalk时,似乎服务器没有运行gulp任务(在服务器上找不到文件'public / js / scripts.js')。
根据要求,这些是来自服务器的最后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...
我做错了什么? 感谢
答案 0 :(得分:0)
您应该提供Elastic Beanstalk尝试运行npm start
后会发生什么的日志。您可以通过转到Logs
>从命令行或控制台获取此信息。 Request Logs
> Last 100 Lines
。
关闭您发布的内容,我将假设问题是您没有在全球范围内安装Gulp。通过运行gulp
,它将在您的bin中查找该可执行文件。即使您gulp
中有package.json
,该可执行文件也不会存在,因为package.json
仅在本地安装它。
如果您在启动命令之前运行npm install -g gulp
该怎么办?您可以在start命令中执行此操作,也可以使用NPM's "scripts"中的任何一个。 preinstall
可能是要使用的人。它看起来像这样:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"gulp": "gulp",
"preinstall": "npm install -g gulp",
"prestart": "npm run gulp",
"start": "node server.js"
},
我还将npm run gulp
移到了prestart
脚本,因为它应该在运行之前运行。