haskellcabalcabal-installcabal-new

Keep cabal new-run alive


I'm running a haskell-based build using cabal the following way in dev mode on ubuntu 20.04:

cabal new-run -- exe:live-docs \
  --database-url='postgres://<user>:<password>@<host>:<port>/<dbname>' \
  serve --enable-admin --admin-assets-dir=../admin/static

What is the best practice to keep the cabal session working in the background (keep-alive) for production use?

I have looked into the Cabal documentation in vain.


Solution

  • If the goal is to avoid cabal's output (as described in your comments), you have two quick options:

    1. Use -v0 to ask it not to output anything. It will still produce output if building your program fails.

      cabal run -v0 live-docs -- --db etc
      
    2. Use cabal to build, and optionally copy it somewhere central, then just... run your program. This is what most people do. To build and run:

      cabal build live-docs # this produces output and is done once
      
      # the next three are essentially equivalent options. you do one of them each
      # time you want to start your program
      `cabal list-bin live-docs` --db etc # OR
      cabal exec live-docs -- --db etc # OR
      ./dist-newstyle/<poke around a bit>/live-docs --db etc
      

      To build and copy somewhere central:

      cabal install exe:live-docs # done once, produces output
      
      live-docs --db etc # each time you want to start your program