使用EB CLI 3.0X将Rails应用程序部署到Elastic Beanstalk

时间:2014-11-29 13:18:06

标签: ruby-on-rails amazon-web-services elastic-beanstalk

我正在尝试使用EB CLI 3.0x重新部署RoR应用程序

我以前在使用Ruby Puma 2.0的Amazon Linux堆栈2014.03上使用EB CLI 2部署我的应用程序已经成功。但是,在Amazon Linux 2014.09上使用Puma 2.0在CLI 3.0上部署应用程序会给我带来错误。

第一个问题是将postgresql-dev重命名为postgresql92-devpostgresql93-dev,这对每个人来说都很常见。但除此之外,我还面临以下问题:

部署环境似乎无法运行bundle installdb migrate / seed等。

更重要的是,实例中缺少环境变量。在我使用EB CLI 2和Amazon Linux 2014.03的部署中,我可以编写.ebextension配置并在/opt/elasticbeanstalk/containerfiles/envvars中使用环境变量。较旧的部署会初始化我可以在配置文件中使用的$EB_CONFIG_APP_PIDS$EB_CONFIG_APP_CURRENT等变量。

然而,新版本在envvars下为我提供了一个相当空的/opt/elasticbeanstalk/support/envvars文件,并且没有以前的环境变量。此外,我必须手动配置我的数据库并将其连接到我的应用程序。

我想知道是否有其他人遇到类似的问题以及是否有任何解决方案可以轻松地从较旧版本的Elastic Beanstalk CLI迁移到较新版本。

如果有人可以指向我自动启动.ebextensions / sidekiqcron services的较新版本,也会很棒。

1 个答案:

答案 0 :(得分:4)

即使它是一个旧线程:

AWS改变了获取此变量的方式,例如:

EB_APP_STAGING_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_staging_dir)

可以通过以下方式获得CONTAINER变量的完整列表:

/opt/elasticbeanstalk/bin/get-config container --output=yaml
---
app_staging_dir: "/var/app/ondeck"
instance_port: '80'
gem_dir: "/opt/elasticbeanstalk/support/gems/puma"
http_port: '80'
app_deploy_dir: "/var/app/current"
node_install_dir: "/opt/elasticbeanstalk/support/node-install"
puma_version: 2.9.1
node_version: 0.10.33
app_log_dir: "/var/app/containerfiles/logs"
ruby_version: 2.1.5
script_dir: "/opt/elasticbeanstalk/support/scripts"
source_bundle: "/opt/elasticbeanstalk/deploy/appsource/source_bundle"
app_pid_dir: "/var/app/containerfiles/pids"
puma_pid_dir: "/var/run/puma"
app_asset_dir: "/var/app/containerfiles/assets"
tarball_url: https://s3-eu-west-1.amazonaws.com/elasticbeanstalk-env-resources-eu-west-1/stalks/eb_ruby_puma_3.11.1/lib/tarballs
puma_log_dir: "/var/log/puma"
app_user: webapp
support_dir: "/opt/elasticbeanstalk/support"

可以运行其他配置类别选项

/opt/elasticbeanstalk/bin/get-config -h
Usage: get-config CATEGORY [OPTIONS]

Categories:
    optionsettings                   environment option settings that affect instance
    container                        container specific configurations
    addons                           addon configurations
    environment                      environment variables
    meta                             EB environment meta-data

Options:
    -k, --key KEY                    Key of specific configurations.
        --output OUTPUT_FORMAT       Output format. Can be JSON or YAML. Default is JSON.
    -n, --namespace NAMESPACE        Otion Setting namespace for retrieval. Only applied to Category optionsettings.
    -o, --option-name OPTION_NAME    Option Setting name for retrieval. Only applied to Category optionsettings.
    -a, --add-on ADDON               Add-on name. Only applied to Category addons.
    -h, --help                       Help

希望这有助于人们将其堆栈升级到2014.09及之后的版本。