Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ctrl+C-ing the server at the REPL exits the process, not just the server #96

Closed
yurivish opened this issue Oct 14, 2017 · 2 comments
Closed

Comments

@yurivish
Copy link

I'm using HTTP.jl to write a little web service. Puzzlingly, Ctrl+C-ing a server started at the REPL with HTTP.serve stops not just the server but also the Julia process if the server actually served any requests. Full log of a minimal case below (The "crash" case required two ^Cs).

This is on 0.6 using the current master branch:

> julia
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: https://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.6.0 (2017-06-19 13:05 UTC)
_/ |\__'_|_|_|\__'_| | Official http://julialang.org/ release
|__/ | x86_64-apple-darwin13.4.0

julia> using HTTP

julia> HTTP.serve(; host=IPv4(127,0,0,1), port=8002, handler=(req, res) -> HTTP.Response("Hi"))
[HTTP - 2017-10-14T16:04:52.177]: starting server to listen on: 127.0.0.1:8002
^C[HTTP - 2017-10-14T16:04:54 ]: interrupt detected, shutting down...

julia> HTTP.serve(; host=IPv4(127,0,0,1), port=8002, handler=(req, res) -> HTTP.Response("Hi"))
[HTTP - 2017-10-14T16:04:56.181]: starting server to listen on: 127.0.0.1:8002
[HTTP - 2017-10-14T16:04:57.868]: throttling 127.0.0.1
[HTTP - 2017-10-14T16:04:57.872]: new tcp connection accepted, reading request...
[HTTP - 2017-10-14T16:04:58.102]: processing on connection i=0...
[HTTP - 2017-10-14T16:04:58.376]: throttling on connection i=0
[HTTP - 2017-10-14T16:04:58.376]: reading request bytes with readtimeout=180.0
[HTTP - 2017-10-14T16:04:59.129]: received request on connection i=0
HTTP.Request:

GET / HTTP/1.1
Connection: keep-alive
Accept-Encoding: gzip, deflate, br
Host: 127.0.0.1:8002
Cache-Control: no-cache
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Upgrade-Insecure-Requests: 1
Accept-Language: en-US,en;q=0.8,ru;q=0.6
Pragma: no-cache
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36


[HTTP - 2017-10-14T16:04:59.527]: responding with response on connection i=0
HTTP.Response:

HTTP/1.1 200 OK
Connection: keep-alive
Content-Type: text/html; charset=utf-8
Date: Sat, 14 Oct 2017 20:04:59
Content-Language: en
Server: Julia/0.6.0
Content-Length: 2

Hi
[HTTP - 2017-10-14T16:04:59.627]: throttling on connection i=0
[HTTP - 2017-10-14T16:04:59.627]: reading request bytes with readtimeout=180.0
[HTTP - 2017-10-14T16:04:59.705]: received request on connection i=0
HTTP.Request:

GET /favicon.ico HTTP/1.1
Connection: keep-alive
Referer: http://127.0.0.1:8002/
Accept-Encoding: gzip, deflate, br
Host: 127.0.0.1:8002
Cache-Control: no-cache
Accept: image/webp,image/apng,image/*,*/*;q=0.8
Accept-Language: en-US,en;q=0.8,ru;q=0.6
Pragma: no-cache
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36


[HTTP - 2017-10-14T16:04:59.705]: responding with response on connection i=0
HTTP.Response:

HTTP/1.1 200 OK
Connection: keep-alive
Content-Type: text/html; charset=utf-8
Date: Sat, 14 Oct 2017 20:04:59
Content-Language: en
Server: Julia/0.6.0
Content-Length: 2

Hi
[HTTP - 2017-10-14T16:04:59.705]: reading request bytes with readtimeout=180.0
^CERROR (unhandled task failure): InterruptException:
Stacktrace:
[1] wait() at ./event.jl:234
[2] wait(::Condition) at ./event.jl:27
[3] stream_wait(::Timer, ::Condition, ::Vararg{Condition,N} where N) at ./stream.jl:42
[4] wait(::Timer) at ./event.jl:357
[5] sleep(::Float64) at ./event.jl:411
[6] process!(::HTTP.Nitrogen.Server{HTTP.http,HTTP.Handlers.HandlerFunction{##3#4}}, ::HTTP.Parser, ::HTTP.Request, ::Int64, ::TCPSocket, ::HTTP.Nitrogen.RateLimit, ::Base.RefValue{Float64}, ::Bool) at /Users/yurivish/.julia/v0.6/HTTP/src/server.jl:192
[7] (::HTTP.Nitrogen.##7#9{HTTP.http,Bool,HTTP.Nitrogen.RateLimit,TCPSocket,Int64,HTTP.Request,HTTP.Parser,HTTP.Nitrogen.Server{HTTP.http,HTTP.Handlers.HandlerFunction{##3#4}}})() at ./task.jl:335
^Cfatal: error thrown and no exception handler available.
InterruptException()
jl_run_once at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/jl_uv.c:132
process_events at ./libuv.jl:82 [inlined]
wait at ./event.jl:216
task_done_hook at ./task.jl:256
jlcall_task_done_hook_21956 at /Applications/Julia-0.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
jl_apply at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/./julia.h:1424 [inlined]
finish_task at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/task.c:232
start_task at /Users/osx/buildbot/slave/package_osx10_9-x64/build/src/task.c:275
> ~
@quinnj
Copy link
Member

quinnj commented Oct 15, 2017

This is a bug in Julia itself; see JuliaLang/julia#19467

@quinnj
Copy link
Member

quinnj commented Oct 26, 2017

Should be fixed on julia master now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants