packages feed

angel (empty) → 0.2

raw patch · 4 files changed

+172/−0 lines, 4 filesdep +MissingHdep +basedep +containerssetup-changed

Dependencies added: MissingH, base, containers, mtl, old-locale, old-time, parsec, process, stm, unix

Files

+ Angel/Main.hs view
@@ -0,0 +1,52 @@+module Main where ++import Control.Concurrent (threadDelay, forkIO, forkOS)+import Control.Concurrent+import Control.Concurrent.STM+import Control.Concurrent.STM.TVar (readTVar, writeTVar)+import Control.Concurrent.STM.TChan (newTChan)+import Control.Monad (unless, when, forever)+import System.Environment (getArgs)+import System.Posix.Signals+import System.IO (hSetBuffering, BufferMode(..), stdout, stderr)++import qualified Data.Map as M++import Angel.Log (logger)+import Angel.Config (monitorConfig)+import Angel.Data (GroupConfig(..))+import Angel.Job (pollStale)+import Angel.Files (startFileManager)++-- |Signal handler: when a HUP is trapped, write to the wakeSig Tvar+-- |to make the configuration monitor loop cycle/reload+handleHup :: TVar (Maybe Int) -> IO ()+handleHup wakeSig = atomically $ writeTVar wakeSig $ Just 1++main = do +    hSetBuffering stdout LineBuffering+    hSetBuffering stderr LineBuffering+    let log = logger "main" +    log "Angel started"+    args <- getArgs++    -- Exactly one argument required for the `angel` executable+    unless (length args == 1) $ error "exactly one argument required: config file"+    let configPath = head args+    log $ "Using config file: " ++ configPath++    -- Create the TVar that represents the "global state" of running applications+    -- and applications that _should_ be running+    fileReqChan <- atomically $ newTChan+    sharedGroupConfig <- newTVarIO $ GroupConfig M.empty M.empty fileReqChan++    -- The wake signal, set by the HUP handler to wake the monitor loop+    wakeSig <- newTVarIO Nothing+    installHandler sigHUP (Catch $ handleHup wakeSig) Nothing++    -- Fork off an ongoing state monitor to watch for inconsistent state+    forkIO $ pollStale sharedGroupConfig+    forkIO $ startFileManager fileReqChan++    -- Finally, run the config load/monitor thread+    runInUnboundThread $ forever $ monitorConfig configPath sharedGroupConfig wakeSig
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright Jamie Turner 2011++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.++    * Neither the name of Jamie Turner nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"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+OWNER OR CONTRIBUTORS 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.
+ Setup.hs view
@@ -0,0 +1,3 @@+#!/usr/bin/env runhaskell+import Distribution.Simple+main = defaultMain
+ angel.cabal view
@@ -0,0 +1,87 @@+-- angel.cabal auto-generated by cabal init. For additional+-- options, see+-- http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr.+-- The name of the package.+Name:                angel++-- The package version. See the Haskell package versioning policy+-- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for+-- standards guiding when and how versions should be incremented.+Version:             0.2++-- A short (one-line) description of the package.+-- Synopsis:            ++-- A longer description of the package.+-- Description:         ++-- The license under which the package is released.+License:             BSD3++-- The file containing the license text.+License-file:        LICENSE++-- The package author(s).+Author:              Jamie Turner++-- Synopsos+Synopsis: Process management and supervision daemon++Description:    @angel@ is a daemon that runs and monitors other processes.  It+                is similar to djb's `daemontools` or the Ruby project `god`.+                .+                It's goals are to keep a set of services running, and to facilitate+                the easy configuration and restart of those services.++                See the homepage for documentation.++-- An email address to which users can send suggestions, bug reports,+-- and patches.+Maintainer:          jamie@bu.mp++Homepage:            http://github.com/jamwt/Angel++-- A copyright notice.+-- Copyright:           ++-- Stability of the pakcage (experimental, provisional, stable...)+Stability:           Stable+Category:            System+Build-type:          Simple++-- Extra files to be distributed with the package, such as examples or+-- a README.+-- Extra-source-files:  ++-- Constraint on the version of Cabal needed to build this package.+Cabal-version:       >=1.6+++source-repository head+    type: git+    location: https://github.com/jamwt/Angel.git++Executable angel+  -- .hs or .lhs file containing the Main module.+  Main-is: Angel/Main.hs+  +  -- Packages needed in order to build this package.+  Build-depends: base >= 4.0 && < 5+  Build-depends: process >= 1.0+  Build-depends: mtl+  Build-depends: MissingH+  Build-depends: parsec+  Build-depends: stm >= 2.0+  Build-depends: containers >= 0.3+  Build-depends: unix >= 2.4+  Build-depends: old-time+  Build-depends: old-locale++  +  -- Modules not exported by this package.+  -- Other-modules:       +  +  -- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source.+  -- Build-tools:         +  +  Ghc-Options: -threaded