弹性beanstalk upstart脚本出错?

时间:2015-01-24 03:15:53

标签: ruby bash elastic-beanstalk upstart puma

我有一个配置了ruby / puma的AWS Elastic beanstalk应用程序。我在实例的/etc/init中看到了这一点。带有

puma.conf文件
$ cat /etc/init/puma.conf
description "Elastic Beanstalk Puma Upstart Manager"

start on runlevel [2345]
stop on runlevel [!2345]

respawn

script
exec /bin/bash <<"EOF"
  EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
  EB_SUPPORT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir)

        . $EB_SUPPORT_DIR/envvars
        . $EB_SCRIPT_DIR/use-app-ruby.sh

  if grep -eq 'true' /etc/elasticbeanstalk/has_puma.txt; then
    exec su -s /bin/bash -c "bundle exec puma -C $EB_SUPPORT_DIR/conf/pumaconf.rb" webapp
  else
    exec su -s /bin/bash -c "puma -C $EB_SUPPORT_DIR/conf/pumaconf.rb" webapp
  fi
EOF
end script

这只是我还是坏了?在终端中运行if条件(grep -eq 'true' /etc/elasticbeanstalk/has_puma.txt;)会引发错误。就像运行整个if块一样。 /etc/elasticbeanstalk/has_puma.txt包含一个字true

我们发现这是因为我们遇到了微妙的应用级别问题,当我们使用bundle exec时这些问题就消失了。

我能够通过修改puma.conf来解决这个问题,

$ cat /etc/init/puma.conf 
description "Elastic Beanstalk Puma Upstart Manager"
EB_SUPPORT_DIR=/opt/elasticbeanstalk/support
start on runlevel [2345]
stop on runlevel [!2345]

respawn

script
exec /bin/bash <<"EOF"
  EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
  EB_SUPPORT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir)

. $EB_SUPPORT_DIR/envvars
. $EB_SCRIPT_DIR/use-app-ruby.sh

  exec su -s /bin/bash -c "cd /var/app/current && bundle exec puma -C $EB_SUPPORT_DIR/conf/pumaconf.rb" webapp
EOF
end script

我必须添加cd才能使用...不太确定。

这是弹性豆茎系统的错误吗?这个解决方案是正确的还是有更清洁/更好的方法来实现这个目标?

0 个答案:

没有答案