on master help sign in
faq: Delete out-of-date section on 'ob run' implementation
commita3e0756d9fcfc53e2b66bcafa8a0828e7639142d authorElliot Cameron <eacameron@gmail.com> dateFri 5 Jun 2020, 11:12 (6 years ago) parent602c73a
1 file changed−61
FAQ.md−61
FAQ.md−61
@@ -3,7 +3,6 @@
331. [How do I fix invalid entitlements? ](#how-do-i-fix-invalid-entitlements)
441. [`ob thunk update` or `ob deploy update` fails](#ob-thunk-update-or-ob-deploy-update-fails)
551. [How do I fix `Ambiguous module name` errors?](#how-do-i-fix-ambiguous-module-name-errors)
6−1. [What does `ob run` actually do?](#what-does-ob-run-actually-do)
76
87### How do I fix invalid entitlements?
98
@@ -60,63 +59,3 @@ error:
6059then specify the package you want in the import, e.g:
6160`import "cryptonite" Crypto.Hash`
6261
63−
64−### What does `ob run` actually do?
65−
66−
67−#### Short version:
68−
69−`ob run` starts a [`ghcid`](https://github.com/ndmitchell/ghcid) process which
70−tries to build your project within a carefully crafted `nix-shell` with all the
71−project's dependencies and,
72−
73−* either displays compilation errors/warnings,
74−* or starts the Obelisk server, which serves:
75− * your backend's route handlers,
76− * the static assets,
77− * the [JSaddle](https://github.com/ghcjs/jsaddle) frontend code (while opening its websocket).
78−
79−#### Longer version:
80−
81−Assuming we are in a project created with `ob init`, `ob run` calls (see
82−`lib/command/src/Obelisk/Command.hs`):
83−
84− nix-shell --pure -A shells.ghc --run 'ob --no-handoff internal run-static-io <real-run-function>'
85−
86−where
87−
88−* `shells.ghc` is defined in `./default.nix` by importing `./.obelisk/impl/default.nix` which
89− is `default.nix` in the present (Obelisk) repository,
90−* `run-static-io` is a logging-enabled command wrapper
91− (cf. `runObelisk` in `lib/command/src/Obelisk/App.hs`).
92−
93−In this case, it runs the function `Obelisk.Command.Command.run` (defined in
94−`lib/command/src/Obelisk/Command/Run.hs`).
95−
96−* It creates a GHCi config from a Nix expression which:
97− * loads three packages: `backend`, `common`, `frontend`,
98− * obtains a free port number.
99−* Then runs `ghcid`
100− * with a command that reruns `Obelisk.Run.run` at each restart (option
101− `--test`).
102−
103−It is defined in `lib/run/src/Obelisk/Run.hs`:
104−
105−* It creates a thread which starts the main backend.
106− This runs `runSnapWithCommandLineArgs` and passes routes:
107− * to the backend (result of the `_backend_run` field of your
108− implementation of the `Backend fullRoute frontendRoute` record),
109− * or to `serveDefaultObeliskApp` (`lib/backend/src/Obelisk/Backend.hs`) to
110− serve static assets.
111−* Starts `runWidget`
112− which itself runs
113− [runSettingsSocket](https://hackage.haskell.org/package/warp-3.2.26/docs/Network-Wai-Handler-Warp.html#v:runSettingsSocket)
114− (the *“TCP listen loop”*):
115− * it binds to TCP socket, and
116− * creates the HTTP connection manager
117− ( [`newManager`](https://hackage.haskell.org/package/http-client-0.6.3/docs/Network-HTTP-Client.html#v:newManager))
118− * calls `obeliskApp` which
119− * has a route to serve the [JSaddle](https://github.com/ghcjs/jsaddle) frontend,
120− * runs the frontend (*on* the server), to produce pre-rendered pages,
121− * starts the JSaddle web-socket,
122− * “falls back” to proxying the backend (`fallbackProxy`).