yesod-bin: The yesod helper executable.

[ mit, program, web, yesod ] [ Propose Tags ] [ Report a vulnerability ]

See README.md for more information


[Skip to Readme]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 1.2.0, 1.2.0.1, 1.2.1, 1.2.2, 1.2.2.1, 1.2.3, 1.2.3.1, 1.2.3.2, 1.2.3.3, 1.2.3.4, 1.2.4, 1.2.4.1, 1.2.5, 1.2.5.1, 1.2.5.2, 1.2.5.3, 1.2.5.4, 1.2.5.5, 1.2.5.6, 1.2.5.7, 1.2.5.8, 1.2.6, 1.2.6.1, 1.2.7, 1.2.7.1, 1.2.7.2, 1.2.7.3, 1.2.7.4, 1.2.8, 1.2.8.1, 1.2.9, 1.2.9.1, 1.2.9.2, 1.2.9.3, 1.2.9.4, 1.2.10, 1.2.10.1, 1.2.10.2, 1.2.10.3, 1.2.11, 1.2.12, 1.2.12.1, 1.2.12.2, 1.2.12.3, 1.2.12.4, 1.2.12.5, 1.2.12.6, 1.2.12.7, 1.2.12.8, 1.2.13, 1.4.0, 1.4.0.1, 1.4.0.2, 1.4.0.3, 1.4.0.4, 1.4.0.5, 1.4.0.6, 1.4.0.7, 1.4.0.8, 1.4.0.9, 1.4.1, 1.4.1.1, 1.4.1.2, 1.4.2, 1.4.3, 1.4.3.1, 1.4.3.2, 1.4.3.3, 1.4.3.4, 1.4.3.5, 1.4.3.6, 1.4.3.7, 1.4.3.9, 1.4.3.10, 1.4.3.11, 1.4.4, 1.4.5, 1.4.5.1, 1.4.6, 1.4.7, 1.4.7.1, 1.4.7.2, 1.4.8, 1.4.9, 1.4.9.1, 1.4.9.2, 1.4.10, 1.4.11, 1.4.12, 1.4.13, 1.4.13.1, 1.4.13.2, 1.4.13.3, 1.4.14, 1.4.15, 1.4.16, 1.4.16.1, 1.4.17, 1.4.17.1, 1.4.18, 1.4.18.1, 1.4.18.2, 1.4.18.3, 1.4.18.4, 1.4.18.5, 1.4.18.6, 1.4.18.7, 1.5.0, 1.5.0.1, 1.5.1, 1.5.2, 1.5.2.1, 1.5.2.2, 1.5.2.3, 1.5.2.4, 1.5.2.5, 1.5.2.6, 1.5.3, 1.6.0, 1.6.0.1, 1.6.0.2, 1.6.0.3, 1.6.0.4, 1.6.0.5, 1.6.0.6, 1.6.1, 1.6.2, 1.6.2.1, 1.6.2.2, 1.6.2.3 (info)
Change log ChangeLog.md
Dependencies aeson, base (>=4.10 && <5), bytestring (>=0.9.1.4), Cabal (>=1.18), conduit (>=1.3), conduit-extra (>=1.3), containers (>=0.2), data-default-class, directory (>=1.2.1), file-embed, filepath (>=1.1), fsnotify, http-client (>=0.4.7), http-client-tls, http-reverse-proxy (>=0.4), http-types (>=0.7), network (>=2.5), optparse-applicative (>=0.11), process, project-template (>=0.1.1), say, split (>=0.2 && <0.3), stm, streaming-commons, tar (>=0.4 && <0.7), text (>=0.11), time (>=1.1.4), transformers, transformers-compat, unliftio, unordered-containers, wai (>=2.0), wai-extra, warp (>=1.3.7.5), warp-tls (>=3.0.1), yaml (>=0.8 && <0.12), zlib (>=0.5) [details]
License MIT
Author Michael Snoyman <michael@snoyman.com>
Maintainer Michael Snoyman <michael@snoyman.com>
Revised Revision 1 made by MichaelSnoyman at 2024-04-03T03:41:08Z
Category Web, Yesod
Home page http://www.yesodweb.com/
Source repo head: git clone https://github.com/yesodweb/yesod
Uploaded by MichaelSnoyman at 2024-02-10T17:07:44Z
Distributions Debian:1.6.0.6, FreeBSD:1.4.13.3, LTSHaskell:1.6.2.3, NixOS:1.6.2.3, Stackage:1.6.2.3
Reverse Dependencies 1 direct, 0 indirect [details]
Executables yesod
Downloads 113009 total (160 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
Last success reported on 2024-02-10 [all 1 reports]

Readme for yesod-bin-1.6.2.3

[back to package description]

yesod-bin: the Yesod executable

This executable is almost exclusively used for its yesod devel capabilities, providing a development server for web apps. It also provides some legacy functionality, almost all of which has been superceded by functionality in the Haskell Stack build tool. This README will speak exclusively about yesod devel.

CAVEAT There may be some issues using yesod devel in Docker-enabled projects. See comment on Github.

Development server

The development server will automatically recompile your application whenever you make source code changes. It will then launch your app, and reverse-proxy to it. The reverse proxying ensures that you can connect to your application on a dedicated port, always get the latest version available, and won't get dropped connections when the app isn't yet ready. Instead, you'll get some very motivating messages:

Motivation

Common workflows

The standard Yesod scaffoldings are configured to work with yesod devel out of the box (though see below for non-Yesod development). For the most part, from within your application directory, you'll just want to run:

  • stack build yesod-bin
  • stack exec -- yesod devel

This will install the corresponding version of the yesod executable into your currently selected snapshot, and then use that executable. (Starting with version 1.5.0, you can be more lax and use a yesod executable compiled for a different snapshot. Once 1.5.0 is more widespread we'll probably update these instructions.)

Some other common questions:

  • If you want to control which port you can access your application on, use the --port command line option, e.g. stack exec -- yesod devel --port 4000. Changing your port inside your source code will not work, because you need to change the reverse proxying port.
  • If you want to run a command after each successful build, you can use stack exec -- yesod devel --success-hook "echo Yay!"
  • If for some reason you want to disable the reverse proxy capabilities, use stack exec -- yesod devel --disable-reverse-proxy

How it works

The workflow of the devel server is pretty simple:

  • Launch a reverse proxy server
  • Use Stack file-watch capability to run a build loop on your code, rebuilding each time a file is modified
  • Have Stack call yesod devel-signal to write to a specific file (yesod-devel/rebuild) each time a rebuild is successful
  • Each time yesod-devel/rebuild is modified:
    • Kill the current child process
    • Get a new random port
    • Tell the reverse proxy server about the new port to forward to
    • Run the application's devel script with two environment variables set:
      • PORT gives the newly generated random port. The application needs to listen on that port.
      • DISPLAY_PORT gives the port that the reverse proxy is listening on, used for display purposes or generating URLs.

Now some weird notes:

  • The devel script can be one of the following three files. yesod devel will search for them in the given order. That script must provide a main function.
    • app/devel.hs
    • devel.hs
    • src/devel.hs
  • Unfortunately, directly killing the ghc interpreter has never worked reliably, so we have an extra hack: when killing the process, yesod devel also writes to a file yesod-devel/devel-terminate. Your devel script should respect this file and shutdown whenever it exists. (It may be fixed in 1.6.0.5.)
  • If your .cabal file defines them, yesod devel will tell Stack to build with the flags dev and library-only. You can use this to speed up compile times (biggest win: skip building executables, thus the name library-only).

If that all seems a little complicated, remember that the Yesod scaffolding handles all of this for you. But if you want to implement it yourself...

Non-Yesod development

If you'd like to use the yesod devel server for your non-Yesod application, or even for a Yesod application not based on the scaffolding, this section is for you! We've got a sample application in the repository that demonstrates how to get this set up. It demonstrates a good way to jump through the hoops implied above.

One important note: I highly recommend putting all of the logic in your library, and then providing a develMain :: IO () function which your app/devel.hs script reexports as main. I've found this to greatly simplify things overall, since you can ensure all of your dependencies are specified correctly in your .cabal file. Also, I recommend using PackageImports in that file, as the example app shows.