I have created a http web service, the concept is taken from the presentation of Quinnj’s MusicAlbum project. 1 thing I am not sure about. If I want to initiate the server with
@async mode from the terminal it initiating and closing the server immediately. Here is the file in the repo . Running
julia --t 2 serve.jl it initiate the server and close it immediately after execution. but if do not use
If your Julia process is not going to do anything other than running the server there is no point in spawning a new task (
@async) for running the HTTP server.
If the process is going to do other things after launching the server you can prevent Julia from exiting by
waiting for the server task:
server_task = @async run_server() # Do other stuff here... # Keep Julia alive for as long as the server is running wait(server_task)
The implementation language of the client doesn’t matter, only the actual HTTP interaction. Different client libraries may have different defaults that could affect the interaction, for example timeouts.
It seems like I miss understood the client part of the Project from Quinnj. Actually he runs the server in the docker. But In his client side probably because he run stuff concurrently so he started the server with
If you are saying that the client and the server are in the same process, then yes, they need to run async so both get time to run. Otherwise, one or the other would block waiting for I/O and the other couldn’t respond. To simulate an environment closer to production, client and server ought to be at least separate processes, or better, running on separate computers or even in separate networks.
Good Point. Thanks for the clarification.