Run cowmachine applications, such as Zotonic, on Roadrunner.
cowmachine runs on Cowboy by default, and lets you pick its HTTP server.
roadrunner_cowmachine is a cowmachine server: set it in your config, and
your listeners, middlewares, controllers, and WebSocket handlers run on
Roadrunner as they are.
roadrunner_cowmachine is in 0.x. The core is functional and covered by tests,
but the API may change between minor versions. Pin an exact version
in your deps if you need stability across upgrades.
Add it next to cowmachine in your rebar.config (latest version on
Hex):
{deps, [
cowmachine,
roadrunner_cowmachine
]}.Make it cowmachine's server in your sys.config:
[{cowmachine, [
{server, roadrunner_cowmachine}
]}].Start listeners with cowmachine_server:start_listener/2, as you would on
Cowboy:
{ok, _} = cowmachine_server:start_listener(my_listener, #{
port => 8000,
middlewares => [my_dispatcher, cowmachine],
env => #{cowmachine_controller => my_controller}
}).It takes the options you already use with cowmachine:
portandip, withipv6_v6onlyfor an IPv6 addresstlswith thesslserver options for HTTPSbacklog,max_connections,num_acceptorsandrequest_timeoutmiddlewaresandenvmetrics_callback, withmetrics_req_filterandmetrics_resp_headers_filter, called once per request with the same metrics as Cowboy'soptions: the server's own options, here any Roadrunner listener option
{ok, _} = cowmachine_server:start_listener(my_listener, #{
port => 8000,
middlewares => [my_dispatcher, cowmachine],
options => #{max_concurrent_requests => 10_000}
}).Middlewares get a request map shaped like Cowboy's, so matching on it
(#{path := Path}, #{bindings := Bindings}) works on every server, and
controllers use cowmachine_req as always.
For the raw request, use cowmachine_cowreq, which has the same functions
as cowboy_req:
execute(Req0, Env) ->
case cowmachine_cowreq:header(~"x-api-key", Req0) of
undefined -> {stop, cowmachine_cowreq:reply(401, Req0)};
_Key -> {ok, Req0, Env}
end.Code that calls cowboy_req to send a response or read the body runs on
Cowboy only.
roadrunner_cowmachine is open source and maintained on personal time. If you or your company find it useful, consider sponsoring.
I also accept coffees ☕
Contributions are welcome! Please see CONTRIBUTING.md for development setup, testing guidelines, and contribution workflow.
Copyright (c) 2026 William Fank Thomé
roadrunner_cowmachine is open-source under the Apache 2.0 License on GitHub.
See LICENSE.md for more information.
