mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-09-17 13:37:20 +03:00
Merge pull request #6745 from urbit/m/dead-agent-503
eyre: serve 503 if bound agent is not running
This commit is contained in:
commit
30dcd3808e
@ -789,8 +789,7 @@
|
||||
%. (~(put by connections.state) duct connection)
|
||||
(trace 2 |.("{<duct>} creating local"))
|
||||
::
|
||||
:_ state
|
||||
(subscribe-to-app [%ours ~] app.act inbound-request.connection)
|
||||
(request-to-app [%ours ~] app.act inbound-request.connection)
|
||||
:: +request: starts handling an inbound http request
|
||||
::
|
||||
++ request
|
||||
@ -964,8 +963,7 @@
|
||||
==
|
||||
::
|
||||
%app
|
||||
:_ state
|
||||
(subscribe-to-app identity app.action inbound-request.connection)
|
||||
(request-to-app identity app.action inbound-request.connection)
|
||||
::
|
||||
%authentication
|
||||
(handle-request:authentication secure host address [suv identity] request)
|
||||
@ -1100,11 +1098,24 @@
|
||||
%^ return-static-data-on-duct status 'text/html'
|
||||
(error-page status authenticated url.request tape)
|
||||
--
|
||||
:: +subscribe-to-app: subscribe to app and poke it with request data
|
||||
:: +request-to-app: subscribe to app and poke it with request data
|
||||
::
|
||||
++ subscribe-to-app
|
||||
++ request-to-app
|
||||
|= [=identity app=term =inbound-request:eyre]
|
||||
^- (list move)
|
||||
^- (quip move server-state)
|
||||
:: if the agent isn't running, we synchronously serve a 503
|
||||
::
|
||||
?. !<(? q:(need (need (rof ~ /eyre %gu [our app da+now] /$))))
|
||||
%^ return-static-data-on-duct 503 'text/html'
|
||||
%: error-page
|
||||
503
|
||||
?=(%ours -.identity)
|
||||
url.request.inbound-request
|
||||
"%{(trip app)} not running"
|
||||
==
|
||||
:: otherwise, subscribe to the agent and poke it with the request
|
||||
::
|
||||
:_ state
|
||||
:~ %+ deal-as
|
||||
/watch-response/[eyre-id]
|
||||
[identity our app %watch /http-response/[eyre-id]]
|
||||
|
@ -375,6 +375,7 @@
|
||||
|= [gang pov=path =view =beam]
|
||||
^- (unit (unit cage))
|
||||
?: =(%gd view) ``noun+!>(%base)
|
||||
?: =(%gu view) ``noun+!>(=(%app1 q.beam))
|
||||
?: &(=(%ca view) =(/gen/handler/hoon s.beam))
|
||||
:+ ~ ~
|
||||
vase+!>(!>(|=(* |=(* [[%404 ~] ~]))))
|
||||
@ -553,6 +554,21 @@
|
||||
(take /watch-response/[eyre-id] ~[/http-blah] sign)
|
||||
=/ headers ['content-type' 'text/html']~
|
||||
(expect-moves mos (ex-continue-response `[3 'ya!'] %.n) ~)
|
||||
::
|
||||
++ test-dead-app-request
|
||||
%- eval-mare
|
||||
=/ m (mare ,~)
|
||||
;< ~ bind:m perform-init-wo-timer
|
||||
;< ~ bind:m (wait ~d1)
|
||||
:: dead-app binds successfully
|
||||
::
|
||||
;< ~ bind:m (connect %dead-app /)
|
||||
;< ~ bind:m (wait ~d1)
|
||||
:: outside requests a path that dead-app has bound to
|
||||
::
|
||||
;< mos=(list move) bind:m (get '/' ~)
|
||||
=/ body `(error-page:eyre-gate 503 %.n '/' "%dead-app not running")
|
||||
(expect-moves mos (ex-response 503 ['content-type' 'text/html']~ body) ~)
|
||||
:: tests an app redirecting to the login handler, which then receives a post
|
||||
:: and redirects back to app
|
||||
::
|
||||
|
Loading…
Reference in New Issue
Block a user