Elastic Beanstalk:自定义Puma配置

Ruby + Puma的当前Beanstalk解决方案堆栈使用/opt/elasticbeanstalk/support/conf/pumaconf.rb的配置文件,并忽略Rails应用程序目录中的config/puma.rb

我可以通过自定义的文件覆盖上面的文件.ebextensions但我犹豫不决,因为我想避免破坏,以防PID路径 – 或者更重要的是 – unix套接字文件在即将推出的解决方案堆栈版本中发生变化。

在Beanstalk上自定义Puma配置的最佳实践是什么?

我们使用Ruby + Passenger,但听起来与您的情况相似。 我们需要自定义存储在/opt/elasticbeanstalk/support/conf/nginx_config.erb的nginx配置文件,所以我们通过.ebextensionssed

这是一个让你入门的例子:

.ebextensions / 01-编辑nginx.config

 container_commands: 01backup_config: command: "cp -n /opt/elasticbeanstalk/support/conf/nginx_config.erb /opt/elasticbeanstalk/support/conf/nginx_config.erb.original" 02edit_config: command: "sh -c \"sed '/string_to_insert_text_after/ i\ \ text_to_be_inserted;' /opt/elasticbeanstalk/support/conf/nginx_config.erb.original > /opt/elasticbeanstalk/support/conf/nginx_config.erb\"" 

这将生成配置文件的备份副本(如果它已经存在,则不会覆盖它,这要归功于-n标志),然后在“string_to_insert_text_after”行之后插入“text_to_be_inserted”行。 您可以将多个sed命令一起管道以插入多行。