Tim*_*Hui 2 ruby-on-rails amazon-web-services ember.js amazon-elastic-beanstalk
我在部署弹性beanstalk rails 4 + ember cli应用程序时遇到问题.我有一个rails应用程序,在根目录中我有一个名为'frontend'的文件夹,其中包含由ember CLI Rails生成的ember应用程序.
我的配置:运行Ruby 2.1的64位Amazon Linux 2015.03 v1.3.1(Puma)
运行eb deploy后,我的活动日志中遇到以下错误:
粗略地说,我明白了
ERROR: Instance: i-25c139e7 Module: AWSEBAutoScalingGroup ConfigSet: null Command failed on instance. Return code: 1 Output: (TRUNCATED)...mber-cli-rails.rb:58:in `compile!'
Run Code Online (Sandbox Code Playgroud)
查看/var/log/eb-activity.log
我第一次得到很多npm ERR!错误:尝试解锁尚未锁定的X.
然后是npm ERR!系统Linux 3.14.35-28.38.amzn1.x86_64 npm ERR!命令"/ usr/bin/node""/ usr/bin/npm""install"npm ERR!cwd/var/app/ondeck/frontend npm ERR!node -v v0.10.35 npm ERR!npm -v 1.4.28 npm ERR!错误的ERR!其他日志记录详细信息可在以下位置找到:npm ERR!/var/app/ondeck/frontend/npm-debug.log npm ERR!不行的代码0耙子中止了!EmberCLI Rails要求你的Ember应用程序有一个插件.
From within your EmberCLI directory please run:
$ npm install --save-dev ember-cli-rails-addon@0.0.11
in you Ember application root: /var/app/ondeck/frontend
Tasks: TOP => assets:precompile => ember:compile
(See full trace by running task with --trace) (Executor::NonZeroExitStatus)
Run Code Online (Sandbox Code Playgroud)
所以我ssh到指定的目录并运行npm install,这也给我留下了很多关于授权的错误.当我使用sudo运行时,模块正确安装,但是当我重新部署我的应用程序时,它给了我完全相同的错误.
我已经尝试了sudo NPM安装和chown -R node_modules webapp,以便webapp组可以访问node_modules文件夹但没有成功.
我讨厌很长的答案,但这种情况非常复杂.
正如上述意见提到,有人发现,主目录为Web应用程序需要的用户要创建(/home/webapp).创建此目录后,节点包管理器(npm)可以无错误地执行.因为AWSEB环境可以扩展,所以SSH进入EB主机并执行一次性安装的包和模块将无法长期运行.从本质上讲,答案归结为以下逻辑步骤:
webapp用户的主目录/home/webapp.npm install你的余烬应用程序.bower install你的ember应用程序.为了解决这个问题,我继续创建了几个.ebextensions在执行期间执行的自定义文件eb deploy.他们在这里按顺序:
.ebextensions/00_option_settings.config - 设置一些EB选项; 例如,在执行期间执行的命令执行的超时长度eb deploy.在这种情况下,所有命令将在1200秒后超时.
option_settings:
- namespace: 'aws:elasticbeanstalk:command'
option_name: 'Timeout'
value: '1200'
Run Code Online (Sandbox Code Playgroud).ebextensions/01_packages.config- 可以通过yum安装软件包并使它们可用于您的eb实例.在这种情况下,我使用yum来安装git,稍后将由bower使用.
packages:
yum:
git: []
Run Code Online (Sandbox Code Playgroud).ebextensions/02_commands.config- 允许您在解压缩上传的应用程序之前运行OS命令eb deploy. 这部分答案满足了这个问题的主题:在我的特定情况下,我需要创建/home/webapp目录,确保它由webapp用户拥有,并且还具有700个权限.最后,我确保全局安装bower,因为我的ember应用程序将需要它.
commands:
01_mkdir_webapp_dir:
# use the test directive to create the directory
# if the mkdir command fails the rest of this directive is ignored
test: 'mkdir /home/webapp'
command: 'ls -la /home/webapp'
02_chown_webapp_dir:
command: 'chown webapp:webapp /home/webapp'
03_chmod_webapp_dir:
command: 'chmod 700 /home/webapp'
04_install_bower_global:
command: 'npm install -g bower'
Run Code Online (Sandbox Code Playgroud).ebextensions/03_container_commands.config - 解压缩应用程序后运行OS命令. 注意:我的ember应用程序位于frontend应用程序源代码目录中.为了安装npm和bower依赖项,需要从前端目录执行npm install和bower install命令.还值得一提的是,bower-install命令需要该标志才能成功,因为执行这些命令的AWS用户具有提升的权限.--allow-root
container_commands:
01_npm_install:
# set the current working directory to fully-qualified frontend
cwd: '/var/app/ondeck/frontend/'
command: 'npm install'
leader_only: 'false'
02_bower_install:
# set the current working directory to fully-qualified frontend
cwd: '/var/app/ondeck/frontend/'
command: 'bower --allow-root install'
leader_only: 'false'
03_seeddb:
# seed my database (has nothing to do with this answer)
command: 'rake db:seed_fu'
leader_only: 'true'
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
1510 次 |
| 最近记录: |