I'd like to run a perl6/raku Cro app as a service behind a frontend webserver.
Just running cro run
won't handle restarting after segfaults & reboots.
Previously with perl5 I've used FastCGI - however Cro::HTTP::Server
's Cro::HTTP::Server.new().start()
idiom doesn't look compatible with FastCGI::Native's while $fcgi.accept() {}
example.
The service.p6
generated by cro stub
does have a SIGINT
handler, however I'm unsure whether this is sufficient to point to it in a systemctl
service, i.e.
[Service]
ExecStart = /path/to/service.p6
How are people currently hosting Cro apps?
cro run
is intended as a development tool, not a deployment one, and so is indeed not a good choice for hosting the services.
All of the Cro services I directly take care of are containerized (some guidance on that here) and then run on a hosted Kubernetes cluster. Kubernetes takes care of the automatic restarts, rolling out new versions, etc. I'm also aware of docker-compose
being used in place of Kubernetes, which I guess works, though I believe that's also considered as primarily a development tool.
Setting it up as a systemctl
service should also work fine, provided that's configured to always restart. However, it seems that you'd want to handle SIGTERM
for the clean shutdown to work instead of SIGINT
(nothing wrong with handling both).
I do also place a frontend web server in front of Cro (using Apache, though nginx would be a fine choice too), and also use that to do some caching of static content also (using content-control
in my routes to describe the cachability).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With