start server function

2 views
Skip to first unread message

tphyahoo

unread,
Dec 2, 2008, 5:51:24 AM12/2/08
to HAppS
Bearing in mind getting my recent hurdles in getting macid state to do
what I wanted, I would like to lobby for a function that creates a
checkpoint before shutdown as the "standard" way of starting happs.
Something like the following, which is an amalgamation of advice
provided in the happs list:

There should probably also be a variant of this that is stateless. I
recall that there used to be a function noState, but
this seems to have disappeared. Has this been replaced with anything.

By the way, the withProgName machinery just ensures that the data
under _local is shared by the program whether run by ghc
i, ghc, compiled, or whatever. The timing information is because,
well, sometimes things are slow and I like to be able to
have hard data on whether there really is a slowdown or this is just
perceptual as programs evolve over time.

******

-- | run the happs server in a way that is smart and avoids gotchas
involved with state migration
smartserver :: (Methods st, Component st, ToMessage a) =>
Conf -> String -> [ServerPartT IO a] -> Proxy st -> IO
()
smartserver conf progName c stateProxy = withProgName progName $ do
putStrLn . ( "starting happs server" ++ ) =<< time
control <- startSystemState stateProxy -- start the HAppS state
system

putStrLn . ( "happs state started" ++ ) =<< time

tid <- forkIO $ simpleHTTP conf c
putStrLn . ( ( "simpleHttp started on port " ++ (show . port $
conf) ++ "\n" ++
"shut down with ctrl-c" ) ++) =<< time

waitForTermination
killThread tid
putStrLn . ( "creating checkpoint: " ++ ) =<< time
createCheckpoint control

putStrLn . ( "shutting down system: " ++ ) =<< time
shutdownSystem control
putStrLn . ( "exiting: " ++ ) =<< time
where time = return . ("\ntime: " ++ ) . show =<<
getClockTime

Lemmih

unread,
Dec 2, 2008, 6:02:25 AM12/2/08
to HA...@googlegroups.com
On Tue, Dec 2, 2008 at 11:51 AM, tphyahoo <thomash...@googlemail.com> wrote:
>
> Bearing in mind getting my recent hurdles in getting macid state to do
> what I wanted, I would like to lobby for a function that creates a
> checkpoint before shutdown as the "standard" way of starting happs.
> Something like the following, which is an amalgamation of advice
> provided in the happs list:

I'm not sure what you're trying to do. If you want a checkpoint at
shutdown, just call 'createCheckpoint' before the end of your
application.

> There should probably also be a variant of this that is stateless. I
> recall that there used to be a function noState, but
> this seems to have disappeared. Has this been replaced with anything.

It's obsolete. If you don't want to use HAppS.State, simply don't use
HAppS.State.

Joining together HAppS.State and HAppS.Server isn't recommended. It's
important to keep in mind that they are two fairly unrelated systems.

--
Cheers,
Lemmih

Reply all
Reply to author
Forward
0 new messages