The daemons package

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain]

Control.Pipe.C3 provides simple RPC-like wrappers for pipes.

Control.Pipe.Serialize provides serialization and incremental deserialization pipes.

Control.Pipe.Socket provides functions to setup pipes around sockets.

System.Daemon provides a high-level interface to starting daemonized programs that are controlled through sockets.

System.Posix.Daemon provides a low-level interface to starting, and controlling detached jobs.

See the README.md file and the homepage for details.


[Skip to ReadMe]

Properties

Versions0.1.0, 0.1.1, 0.1.2, 0.2.0, 0.2.1, 0.2.1
Change logNEWS.md
Dependenciesbase (==4.*), bytestring, cereal (>=0.4.0), containers, daemons, data-default, directory, filepath, ghc-prim, network, pipes (>=4.0.0), transformers, unix [details]
LicenseGPL-3
AuthorAlexandru Scvortov <scvalex@gmail.com>
Maintainerscvalex@gmail.com
CategorySystem, Control, Network
Home pagehttps://github.com/scvalex/daemons
Source repositoryhead: git clone git://github.com/scvalex/daemons.git
Executablesname, queue, addone, memo
UploadedThu Oct 3 18:47:08 UTC 2013 by AlexandruScvortov

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees

Readme for daemons-0.2.1

daemons

Daemons in Haskell made fun and easy

Example

Here's AddOne, a simple daemon that waits for a number and responds with the incremented number.

import Data.Default ( def )
import System.Environment ( getArgs )
import System.Daemon

addOne :: Int -> IO Int
addOne n = return (n + 1)

main :: IO ()
main = do
    ensureDaemonRunning "addOne" def addOne
    [n] <- getArgs
    res <- runClient "localhost" 5000 ((read n) :: Int)
    print (res :: Maybe Int)

Running it, we see:

% addone 22
Daemon started on port 5000
Just 23
% addone 41
Just 42

The two important functions above are ensureDaemonRunning, which checks if a daemon named addOne is already running, and starts it if not, and runClient which connects to the daemon running on localhost:5000, passes it a number, and waits for the response.

What would I use this for?

Tutorials and examples

Installation

This package is on Hackage. To install it, run:

cabal update
cabal install daemons

Modules

See also