Safe HaskellSafe-Infered



Executing jobs as processes

The protocol works as follows (MP = master process, FP = forked process):

  • MP sets its own livelock as the livelock of the job to be executed.
  • FP creates its own lock file and sends its name to the MP.
  • MP updates the lock file name in the job file and confirms the FP it can start.
  • FP calls executeFile and replaces the process with a Python process
  • FP sends an empty message to the MP to signal it's ready to receive the necessary information.
  • MP sends the FP its job ID.
  • FP sends an empty message to the MP again.
  • MP sends the FP its live lock file name (since it was known only to the Haskell process, but not the Python process).
  • Both MP and FP close the communication channel.



rethrowAnnotateIOError :: String -> IO a -> IO aSource

runProcess :: JobId -> Client -> IO FilePath -> ((String -> IO ()) -> JobId -> Client -> IO Fd) -> IO ()Source

forkWithPipe :: ConnectConfig -> (Client -> IO ()) -> IO (ProcessID, Client)Source

killProcessOnError :: (FromString e, Show e) => ProcessID -> Client -> (String -> ResultT e (WriterLogT IO) ()) -> ResultT e (WriterLogT IO) ()Source

data ForkProcessRet Source


ForkJob (FilePath, ProcessID) 
ForkPostHooks ProcessID 

forkProcessCatchErrors :: (Show e, FromString e) => (Client -> IO ()) -> (ProcessID -> String -> ResultT e (WriterLogT IO) ()) -> (ProcessID -> Client -> ResultT e (WriterLogT IO) ForkProcessRet) -> ResultT e IO ForkProcessRetSource



:: (FromString e, Show e) 
=> QueuedJob

a job to process

-> FilePath

the daemons own livelock file

-> (FilePath -> ResultT e IO ())

a callback function to update the livelock file and process id in the job file

-> ResultT e IO (FilePath, ProcessID) 

Forks the job process and starts processing of the given job. Returns the livelock of the job and its process ID.

forkPostHooksProcess :: (FromString e, Show e) => JobId -> ResultT e IO ProcessIDSource

Forks the process and starts the processing of post hooks for the opcode whose execution was unfinished due to job process disappearing.