If you need to hook into the Lono boot process super-early on, Lono boot hooks are designed for that.
- They run very early in the Lono boot process.
- They are useful for setting shared global values like env vars.
- Boot hooks are ruby files that get required. It’s nice and simple. There’s no interface to learn.
Lono will searches 2 files in the
config folder. If the files exist, they will be ran in this order.
- config/boot.rb: Always runs.
- config/boot/LONO_ENV.rb: Runs based on the env. IE:
Both files are required and ran if they both exists. Since the
LONO_ENV one runs second, it can be used to override previously set values.
Example: Default LONO_ENV
If you prefer a different default than
ENV['LONO_ENV'] ||= 'prod'
This changes the default for everyone using the project, but still allows them to control the default by adding
export LONO_ENV=dev to their
Example: Auto-Switch AWS_PROFILE
One useful example is switching
AWS_PROFILE based on the
ENV['AWS_PROFILE'] = 'dev'
This example is for
AWS_PROFILE, but you can can do similiar switch logic with other env vars, etc.
Please refer to the boot source code for more details: lono/booter.rb