-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Automatically spin up and spin down local daemons
--
-- Gargoyle is a framework for managing daemons from Haskell. In the
-- current release the only requirement is that the daemon be able to
-- communicate over a Unix domain socket. See gargoyle-postgresql
-- for a fully worked out example.
--
-- To use Gargoyle the client must:
--
--
-- - Define a value of the Gargoyle type which specifies how to
-- administer the daemon.
-- - Create an executable whose main is gargoyleMain. The
-- name of this executable should match the executable name specified in
-- the _gargoyle_exec field of the Gargoyle.
-- - The client will run their code with withGargoyle to gain
-- access to the daemon.
--
@package gargoyle
@version 0.1
-- | Utilities for running a daemon in a local directory
module Gargoyle
data Gargoyle pid a
Gargoyle :: FilePath -> (FilePath -> IO ()) -> (FilePath -> IO pid) -> (pid -> IO ()) -> (FilePath -> IO a) -> Gargoyle pid a
-- | The path to the executable created with gargoyleMain which will
-- serve as the daemon monitor process.
[_gargoyle_exec] :: Gargoyle pid a -> FilePath
-- | The action to run in order to populate the daemon's environment for
-- the first run.
[_gargoyle_init] :: Gargoyle pid a -> FilePath -> IO ()
-- | The action to run in order to spin up the daemon on every run. This
-- happens after _gargoyle_init if it also runs.
[_gargoyle_start] :: Gargoyle pid a -> FilePath -> IO pid
-- | The action to run when the monitor process detects that no clients are
-- connected anymore.
[_gargoyle_stop] :: Gargoyle pid a -> pid -> IO ()
-- | Run a command which knows about the working directory of the daemon to
-- collect runtime information to pass to client code in
-- withGargoyle.
[_gargoyle_getInfo] :: Gargoyle pid a -> FilePath -> IO a
-- | Run an IO action while maintaining a connection to a daemon. The
-- daemon will automatically be stopped when no clients remain. If the
-- daemon has not yet been initialized, it will be. The counterpart of
-- this function is gargoyleMain which should be used to produce
-- an executable that will monitor the daemon's status.
withGargoyle :: Gargoyle pid a -> FilePath -> (a -> IO b) -> IO b
-- | Run a local daemon over a domain socket; the daemon will be
-- automatically stopped when no clients remain. This function assumes
-- that the daemon has already been initialized in the specified
-- location. This function should be used as the main function of an
-- executable which will then be invoked by calling withGargoyle
-- in the client code to monitor the daemon's status.
gargoyleMain :: Gargoyle pid a -> IO ()