restricted-workers-0.1.1: Running worker processes under system resource restrictions

Safe HaskellNone

System.Restricted.Worker

Contents

Description

Main entry point of the library

Synopsis

Exposed modules

Creating workers

mkDefaultWorker :: String -> FilePath -> LimitSettings -> Worker aSource

Create an uninitialized worker

startWorkerSource

Arguments

:: (WorkerData w, MonadIO (WMonad w), MonadBase (WMonad w) m) 
=> String

Name

-> FilePath

Socket

-> Maybe (IO Handle)

Where to redirect stdout, stderr

-> LimitSettings

Restrictions

-> WMonad w (WData w)

Pre-forking action

-> (WData w -> Socket -> IO ())

Socket callback

-> WMonad w (Worker w, RestartWorker m w) 

Start a general type of worker.

The pre-forking action is a monadic action that will be run prior to calling forkWorker. It might be some initialization code, running the DB query, anything you want. The resulting WData will be passed to the callback.

The socket that is passed to the callback is a server socket.

startIOWorkerSource

Arguments

:: String

Name

-> LimitSettings

Restrictions

-> FilePath

UNIX socket

-> (Handle -> IO ())

Callback

-> IO (Worker IOWorker, RestartWorker IO IOWorker) 

Start a worker of type IOWorker The callback function is called every time a connectino is established

>>> startIOWorker "test" "/tmp/test.sock" $ \h -> hPutStrLn h "hello, world"

Quering and killing workers

killWorker :: Worker a -> IO (Worker a)Source

Kill a worker. Takes an initialized worker, returns non-initialized one.

workerAlive :: Worker a -> IO BoolSource

Checks whether the worker is alive

connectToWorker :: Worker a -> IO HandleSource

Connect to the worker's socket and return a handle