packages feed

Buster (empty) → 0.1.0

raw patch · 7 files changed

+215/−0 lines, 7 filesdep +basedep +bytestringdep +conduitsetup-changed

Dependencies added: base, bytestring, conduit, data-default, errors, hinotify, hslogger, hspec, hspec-expectations, http-conduit, http-types, string-qq, temporary, transformers, unbounded-delays, unix, yaml

Files

+ Buster.cabal view
@@ -0,0 +1,61 @@+name:                Buster+version:             0.1.0+synopsis:            Hits a set of urls periodically to bust caches+description:+  Buster is a simple tool to periodically make requests to a list of URLs. The+  main use case for this is to bust caches.+license:             MIT+license-file:        LICENSE+author:              Michael Xavier <michael@michaelxavier.net>+maintainer:          Michael Xavier <michael@michaelxavier.net>+copyright:           (c) 2012 Michael Xavier+category:            Web+build-type:          Simple+cabal-version:       >=1.8+tested-with:         GHC == 7.6.1+extra-source-files:+  README.md+  LICENSE+  examples/example.yml+homepage:           http://github.com/michaelxavier/Buster+bug-reports:        http://github.com/michaelxavier/Buster/issues++executable buster+  hs-source-dirs:      src+  main-is:             Buster/Main.hs+  ghc-options: -threaded -Wall -fno-warn-unused-do-bind+  build-depends:  base >= 4 && < 5,+                  bytestring ==0.10.*,+                  conduit ==0.5.*,+                  yaml ==0.8.*,+                  errors ==1.3.*,+                  unix >=2.4.2.0,+                  http-conduit ==1.8.*,+                  http-types ==0.7.*,+                  unbounded-delays ==0.1.*,+                  data-default ==0.5.*,+                  hslogger ==1.2.*,+                  transformers ==0.3.*,+                  hinotify ==0.3.*++test-suite spec+  type:           exitcode-stdio-1.0+  main-is:        Spec.hs+  hs-source-dirs: test,src+  build-depends:  base >= 4 && < 5,+                  bytestring ==0.10.*,+                  hspec == 1.4.*,+                  hspec-expectations == 0.3.*,+                  string-qq,+                  http-types ==0.7.*,+                  temporary ==1.1.*,+                  yaml ==0.8.*,+                  -- WHY?+                  hslogger ==1.2.*,+                  unix >=2.4.2.0,+                  errors ==1.3.*,+                  http-conduit ==1.8.*++source-repository head+  Type:     git+  Location: git://github.com/MichaelXavier/Buster.git
+ LICENSE view
@@ -0,0 +1,25 @@+The following license covers this documentation, and the source code, except+where otherwise indicated.++Copyright 2012, Michael Xavier. All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++* Redistributions of source code must retain the above copyright notice, this+  list of conditions and the following disclaimer.++* Redistributions in binary form must reproduce the above copyright notice,+  this list of conditions and the following disclaimer in the documentation+  and/or other materials provided with the distribution.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY EXPRESS OR+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO+EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,+OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,57 @@+Buster+====+[![Build Status](https://travis-ci.org/MichaelXavier/Buster.png?branch=master)](https://travis-ci.org/MichaelXavier/Buster)++Utility for periodically hitting URLs. The intended use case is forcing caches+to be busted.++Building+====+Run `make`. Use a recent version of GHC. Requires cabal-dev. ++Usage+=====++`buster config.yml`++The program will log to stdout. If you want to reload the config without+stopping the program, send it a HUP signal:++`kill -HUP pid-of-buster`++Configuration+=============++Take a look in the example directory. Buster is configured with a yaml file:++```yaml+verbose: true+monitor: false+log_file: /var/log/buster.log+urls:+- url: http://www.example.com+  interval: 5+  method: GET+- url: http://www.example.net+  interval: 2+  method: GET+```++Interval is measured in seconds. Monitor will begin auto-loading your config.+If you have a process running and you decide you want the config monitored,+send a HUP to the process and from then on it will monitor the file. If no+`log_file` config is specified, it will log to stdout.++Status+======+The project currently works. Here are some improvements I want to make++* Release to hackage++Development+===========++1. Fork the project.+2. Make your changes in a feature branch.+3. Run tests with `make test`.+4. Send a pull request.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ examples/example.yml view
@@ -0,0 +1,10 @@+verbose: true+monitor: true+log_file: /tmp/buster.log+urls:+- url: http://www.example.org+  interval: 5+  method: GET+- url: http://www.example.net+  interval: 2+  method: GET
+ src/Buster/Main.hs view
@@ -0,0 +1,59 @@+module Main (main) where++import Control.Applicative ((<$>))+import Control.Error.Script (runScript,+                             scriptIO)+import Control.Error.Safe (tryHead)+import System.Environment (getArgs)++import Buster.Pool (newPool,+                    startPool,+                    stopPool)+import Buster.Config (installReloadHandler,+                      reloadConfig,+                      summonConfig,+                      setupConfigWatch)+import Buster.Types+import Buster.Logger+import Buster.Monitor++main :: IO ()+main = runScript $ do+         args       <- scriptIO getArgs +         configFile <- tryHead "Specify a config file" args++         scriptIO $ do+          configWatch <- setupConfigWatch++          debugM "Loading initial config"++          reloadConfig configFile configWatch++          debugM "Installing Signal Handlers"++          installReloadHandler configFile configWatch++          run configFile configWatch++--TODO: takMVar is a leaky abstraction here+run :: FilePath -> ConfigWatch -> IO ()+run configFile configWatch = runScript $ scriptIO $ runWithConfig configFile configWatch =<< summonConfig configWatch++runWithConfig :: FilePath -> ConfigWatch -> Config -> IO ()+runWithConfig configFile configWatch cfg = do +  stoppedPool   <- newPool cfg+  pool          <- startPool stoppedPool+  newCfg <- withMonitoring $ \inotify -> do+    mayWatchDesc  <- if configMonitor cfg+                      then +                        Just <$> installMonitor inotify configFile configWatch+                      else return Nothing+    newCfg        <- summonConfig configWatch++    case mayWatchDesc of+      Just desc -> uninstallMonitor configFile desc+      _         -> return ()+    return newCfg++  stopPool pool+  runWithConfig configFile configWatch newCfg
+ test/Spec.hs view
@@ -0,0 +1,1 @@+{-# OPTIONS_GHC -F -pgmF hspec-discover -optF --nested #-}