Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truly static assets #8

Closed

Conversation

solidsnack
Copy link

It would ease deployment for some of us (who are not deploying via Cabal or
system images) if the assets were inlined during the build.

This patch is obviously a shortcut but I thought I'd run the idea by you once
I got it working, before trying to build out something more complete using
embedDir from file-embed to do the directory inlining and route handling
without the aid of Bash.

If inlined assets are deemed valuable to the project then I will endeavour to
submit a more robust patch.

Here is the program I used for testing:

#!/usr/bin/env runhaskell
{-# LANGUAGE OverloadedStrings #-}

import System.Remote.Monitoring
import System.Remote.Counter

import Control.Concurrent

main = do
     handle <- forkServer "localhost" 8000
     counter <- getCounter "iterations" handle
     let loop = inc counter >> threadDelay 250000 >> loop
     loop

It appears the stats polling works by reloading with a different content-type.
@tibbe
Copy link
Collaborator

tibbe commented Dec 13, 2012

I rather not add a Template Haskell dependency. Could you explain what you want to do a bit more in detail? Couldn't you just copy the assets somewhere and set Cabal data_dir override environment variable so the application can find them?

@solidsnack
Copy link
Author

Couldn't you just copy the assets somewhere and set Cabal data_dir override environment variable so the application can find them?

When I think about how that would work, I can't see anything very clean or simple. Wrapping the application in a shell script or using sed+bash to sub in a line in the main source file to set the environment variable are not a clear win relative to Template Haskell. And then there is the script that finds the assets...

Many Haskell programs can be shipped as standalone binaries (something we do for some at Erudify) and these programs -- not necessarily web programs, but long running services nonetheless -- could benefit from an optional "inspector mode" where EKG is turned on.

The wisdom of packing your assets in your Jar files has long been recognized. Since Haskell allows binary deployments it seems natural to include the assets in the binaries when that is feasible.

@tibbe
Copy link
Collaborator

tibbe commented Dec 16, 2012

Having quite a lot of experience working with distributing binaries to remote servers at work, I would recommend that you try to find a more scalable approach than including everything in the executable. You say that Jar files are a good example, but Jar file are simply zip files with that are unzipped upon execution. I would suggest you try something similar.

I don't want to be in a position where I will be limited to use TH to inline all resources in ekg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants