I’m using Mux.jl to run a web server. My code is in a module with the following structure:
module MyApp using Mux # all app functions here function startserver() # setup routes here (using the functions above) @app webserver = (routes...) serve(webserver) end end
Everything works perfectly when I run it from the REPL with
using MyApp; startserver(). The server runs in the background within that session. In other words, I can type commands and do other stuff in the REPL while the server is online responding to all requests I make in a browser. When I exit Julia, the server naturally goes down. So far so good.
Now I want to SSH into my computer and start the web server, and keep the server running after I exit the terminal window. I thought something like this at the Linux command line would work:
nohup julia -e 'using MyApp; startserver()' &
However, the process immediately terminates after starting the server (printing
 Done) and the server goes down. Same result when I put those two commands in a script and call it. How can I keep the server alive?