Hi @krzykamil! Before considering this documentation PR, I wanted to take an extra moment to verify the behaviour.
To do this, I created a fresh Hanami app, threw an action into app/actions/env.rb
:
module FreshApp
module Actions
class Env < FreshApp::Action
def handle(request, response)
response.body = "Hanami is in #{Hanami.env} mode"
end
end
end
end
Chucked it into the routes:
module FreshApp
class Routes < Hanami::Routes
root to: "env"
end
end
And then I fired up the server. First in the default mode, which should be development:
$ bundle exec hanami server
$ curl http://localhost:2300
Hanami is in development mode
So yep, that checks out.
Now I set the env to production using HANAMI_ENV=production
. Still using hanami server
:
$ HANAMI_ENV=production bundle exec hanami server
$ curl http://localhost:2300
Hanami is in production mode
So this looks like hanami server
is correctly started in production mode.
This is the same when passing -e production
:
$ bundle exec hanami server -e production
$ curl http://localhost:2300
Hanami is in production mode
The one strange thing is that Puma reports as being in development mode:
$ bundle exec hanami server -e production
23:23:01 - INFO - Using Guardfile at /Users/tim/Source/hanami/scratch/fresh_app/Guardfile.
DEPRECATION WARNING: Lumberjack.unit_of_work will be removed in version 2.0. Use Lumberjack::Logger#tag(unit_of_work: id) instead. Called from /Users/tim/.local/share/mise/installs/ruby/3.4.2/lib/ruby/gems/3.4.0/gems/guard-2.19.1/lib/guard/runner.rb:18:in 'Guard::Runner#run'
23:23:01 - INFO - Puma starting on port 2300 in development environment.
23:23:01 - INFO - Guard is now watching at '/Users/tim/Source/hanami/scratch/fresh_app'
Puma starting in single mode...
* Puma version: 6.6.0 ("Return to Forever")
* Ruby version: ruby 3.4.2 (2025-02-15 revision d2930f8e7a) +PRISM [arm64-darwin24]
* Min threads: 5
* Max threads: 5
* Environment: development. <======= ****THIS BIT HERE****
* PID: 15893
* Listening on http://0.0.0.0:2300
* Starting control server on http://127.0.0.1:9293
* Starting control server on http://[::1]:9293
Use Ctrl-C to stop
Perhaps that was the thing that was throwing you off? Because otherwise, the Hanami app itself appears to be correctly in production whenever we tell it to be.