GenieFramework/Genie.jl

Simple server in multi-threaded julia

Open

#151 opened on Jul 19, 2019

View on GitHub
 (24 comments) (1 reaction) (1 assignee)Julia (2,408 stars) (186 forks)batch import
TODOhelp wantedparallelism

Description

Describe the bug I like to run a server on the main thread in a multi-threaded julia (e.g. julia -p4). I don't need to handle requests on multiple threads, however, I need the threads for some calculations.

I get the following error:

From worker 2:    2019-07-19 08:51:57:ERROR:Main: / 404
From worker 2: 

To Reproduce

Run the following code with julia -p 2

using Genie, Genie.Router, Genie.Renderer, Genie.Requests
using HTTP
using Distributed

println("Started julia with $(nworkers()) threads.")

Genie.config.run_as_server = true

route("/") do
    (:result => "Hello") |> json
end

Genie.startup()

Open the site.

Expected behavior The request is handled by the main thread.

Contributor guide