Skip to content
This repository has been archived by the owner on Dec 31, 2022. It is now read-only.

establish_connection after preloading? #198

Closed
cschulte22 opened this issue Nov 29, 2018 · 0 comments
Closed

establish_connection after preloading? #198

cschulte22 opened this issue Nov 29, 2018 · 0 comments

Comments

@cschulte22
Copy link

I was looking into optimizing web server memory with puma and ran across this article: https://www.speedshop.co/2017/10/12/appserver.html

It says that you should turn on preload_app! and that you need to re-establish your database connections in the on_worker_boot block like this:

on_worker_boot do
  # Valid on Rails 4.1+ using the `config/database.yml` method of setting `pool` size
  ActiveRecord::Base.establish_connection
end

When I went to do this I noticed that preload_app! is turned on by default, but there's no establish_connection section in the on_worker_boot block. I know that I could add this myself, but it seems like that should be part of the default configuration when preload_app is turned on (since it is by default.

Does anyone know whether or not it's even necessary? It would seem as though it isn't since I've been (unknowingly) running with preloading turned on for the last year or so.

The Heroku docs also mention the same thing for what it's worth: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot

@ajgon ajgon closed this as completed in dfd2cc1 Jan 5, 2019
kpheasey added a commit to kpheasey/opsworks_ruby that referenced this issue Apr 11, 2019
* add symlinks for node_modules and public/packs

* install node lts and yarn

* chore: Fixed broken docker build

Resolves ajgon#153

* fix(chef): Downgraded apt cookbook below version 7

The `ruby-ng` cookbook depends on the `apt` cookbook, which is not
compatible with Chef 12. The `apt` version needs to be set to <7.0.0 in
the metadata for now.

Unfortunately, berkshelf does not detect that the chef versions of the
cookbooks are incompatible.

Resolves ajgon#151

* install node lts and yarn

* fix(chef): Removed broken `deployer` cookbook

Resolves ajgon#155

* chore: Version bump

* feat(appserver): add additional puma configuration options

* Tell Puma to do a rolling restart instead of a stop/start on a deploy
* Allow Puma hooks to be defined in attributes
* Add default content to puma hooks
* stick with original stop/start cycle for puma and remove rolling restarts
* cleanup appserver.service script, allow after-deploy action to be configured
* handle default case for after_deploy properly
* feat(appserver): add additional puma configuration options

* fix(setup): Fixed `deployer` user setup

When setting up new user in Chef 12, a `manage_home true` setting is
required. This commit adds it back.

Fixes ajgon#159

* fix(appserver): moved env files creation to before_symlink phase

Fixes ajgon#157

* feat(ruby): introduced new `ruby-version` JSON parameter.

This removes a misleading `ruby-ng.ruby_version` paramater in favor of
new universal `ruby-version`. The problem was, that the old one was used
for both distributions (Ubuntu and Amazon Linux) while in fact,
`ruby-ng` was referring to Ubuntu-only cookbook.

The new parameter is distro-agnostic and cookbook-agnostic, clearly
speaking it's intention.

Resolves ajgon#156

BREAKING CHANGE: If you were using `ruby-ng.ruby_version` JSON
configuration parameter in your stack/layer configuration, please change
it to `ruby-version`. Since `ruby-version` is set by default to the
freshest version of ruby available, you may end up with unexpected
upgrade of ruby on your system.

* chore: added github issue template

* chore: Version bump

* feat(appserver): support rails restart command on puma.

* fix: do not read pidfile at each stop retry (prevent from early pidfile deletion)

Fixes ajgon#163

* feat(db): added postgis driver

Resolves ajgon#165

* fix(framework): added environment variables context to bundle install

Fixes ajgon#167

* chore: Version bump

* fix: add Apache 2.4's "Require all granted" to apache2+passenger config file (ajgon#171)

* fix(webserver): add `X-Content-Type-Options: nosniff` to assets served by rails for extra security

* feat(webserver): hardened security headers, disabled tls1.0 and tls1.1 for non-legacy SSL config

BREAKING CHANGE: If you are using SSL in your project, TLSv1.0 and
TLSv1.1 has been disabled for all responses - only TLSv1.2 is served. If
you still need older ciphers, consider using
`app['webserver']['ssl_for_legacy_browsers']` configuration option.

* chore: Version bump

* feat(database): added aurora-postgres as an accepted engine for Postgres RDS

* feat(appserver): add port configuration

* feat(webserver): add support for `force_ssl` attribute

Resolves ajgon#189

* chore: Version bump

* fix(db): Fix typo for aurora postgresql

* feat(worker): Support Shoryuken worker library

Add support for Shoryuken job runner implemented on Amazon SQS https://github.com/phstc/shoryuken

* chore: Version bump

* fix: Lock the windows cookbook dependency to maintain chef 12 compatibility (ajgon#196)

* chore: gems update

* fix: Ensure shared/system dir is created (ajgon#197)

This directory is symlinked by default here:

https://github.com/ajgon/opsworks_ruby/blob/6e2328941996d98316657d7a52c98de6982068a5/attributes/default.rb#L21

But the directory is never created and we're left with a broken symlink.

* fix: register gpg public key for nginx on ubuntu18.04LTS (ajgon#201)

* fix(setup): added support for bundler 2.x and rubygems 3.x

Resolves ajgon#203

* feat(ruby): Added support for ruby 2.6

* feat(appserver): re-establish database connections when preloading app

More info: https://www.speedshop.co/2017/10/12/appserver.html#copy-on-write-behavior

Resolves ajgon#198

* fix(apache): fix infinite redirect loop on apache, when rails `force_ssl` is enabled

Fixes ajgon#206

* fix(nginx): add missing `nosniff` header for SSL sessions in nginx

* test: fix broken converges for apache tests

* fix(appserver): fixed Puma config compatibility with older versions of Puma

Resolves ajgon#207

* fix(webserver): Align SSL directory between template & driver

Webserver templates now get the SSL certificate path from driver options.

Resolves ajgon#205

* chore: update copyright information

* chore: Version bump

* fix(apache): fix apache serving assets rather than proxying to app server (ajgon#210)

* feat(apache): apache configuration to use appserver’s port provided in custom json

* fix(appserver): Compare lockfiles instead of main Gemfile

* fix(worker): adapted monit config for sidekiq 6.x

Fixes ajgon#215
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant