How to run Snap haskell webapp in production?

后端 未结 3 1974
隐瞒了意图╮
隐瞒了意图╮ 2021-01-30 11:14

I\'ve installed Snap/Haskell on my production Ubuntu server (on EC2), and checked-out my project - but how do I run it?

I mean, locally, I run it from command line:

3条回答
  •  时光取名叫无心
    2021-01-30 11:48

    Yes, snap-server is its own server, which means compilation of your Haskell/Snap app leaves you with an executable that you can literally run from the command line to host your site. That's it, there's no external server like apache or nginx to tie into. You can setup reverse proxies if needed, but that's up to you.

    Here's what I do with most of my serious deployments:

    • Compile on the same linux box or a compatible machine - I almost always use cabal-dev for sandboxing
    • Command line arguments: cabal-dev/bin/myapp -p 8010 -e prod +RTS -A4M -qg1
    • I run on an unprivileged, non-default port (8010 above) so that I can use a load balancer to forward requests to it. This also allows me to run multiple snap apps per linux box if needed.
    • Then I use a simple process monitoring application to make sure it stays up. You can use:
      • god: http://godrb.com/
      • angel: https://github.com/jamwt/Angel
      • supervisor: http://supervisord.org/
    • One the monitor is set up, you can just send a HUP signal to your application whenever you want to restart and the monitoring app will just bring it back up.
    • I'm a big fan of Fabric for deployment automation. You can handle remote synching, restart, etc. all using fabric.

    Hope this helps.

提交回复
热议问题