Hi all,
I have developped an app in Julia that will served by a webserver made of HTTP.jl functions.
I want to use it in a production environment.
It means at least:
- to start it properly,
- keep it running in the background,
- have some robustness to errors.
Do you have some best practices, tutorials, content that would help that setup of the server (no Docker and a low volume of requests to that server, perf should not be an issue)?
I have long considered using Genie.jl to assist me on that task, but I prefer more low level approaches with HTTP.jl at this time (the tutorial of Quinnj was very help MusicAlbums to design the app and server).
Thanks!
Here are couple pointers/notes for a Julia service I have running. It’s relatively low volume / critically, so there would be room to make things more resilient.
NGINX is the main webserver and proxies requests to the Julia app. This works the same for Julia as essentially any other language. My Julia application is served to localhost (HTTP.serve(router, Sockets.localhost, 8081)
) then in the NGINX config
# other config omitted...
server {
listen 80 default_server;
listen [::]:80 default_server;
location /api/ {
proxy_pass http://localhost:8081/api/;
}
}
This proxies all requests to /api
on the server to the Julia application.
I’m doing nothing special to keep the server running, just starting as a background process in bash, like this.
julia --project='MyProject' -e 'using MyProject; MyProject.serve()' &
In practice it has never crashed, so I’ve never bothered with anything more robust, but could instead using something like pm2, systemd, whatever to make a more resilient service.
I am using a Docker container to set up the julia env, but it would work identically on a plain server.
3 Likes