16:20:04 <lontong> Hi, what's the best way to call a bash script from a happstack app?
16:22:31 <lontong> because of the execution time of my bash script, both runCommand and system (almost) always produces timeout
16:38:00 <donri> lontong: well you could forkIO if you don't need the output in the response
16:44:45 <lontong> donri, is it safe to forkIO?
16:45:24 <donri> it's not made any less safe because of happstack anyway
16:46:03 <lontong> my bash script is basically phantomJS that screen captures website
16:46:52 <lontong> i used to loop the doesFileExists to check if the screencapture already created or not
16:47:10 <donri> ok, you probably want to forkIO and return a response that says "hey i'm working on it, come back later"
16:48:15 <lontong> but that loop makes my app so unstable
16:49:07 <lontong> so right now i'm thinking about moving the loop part to that bash script and the happstack simply forkIO that script and let it proceed itself
16:49:51 <donri> forkIO $ do system "run that thing"; putMVar foo True
16:50:19 <donri> [strawman code, you want something a bit more involved, but still]
16:54:20 <lontong> wow, thanks donri.. i guess i'll try to add the putMVar part to ensure the thread completion
16:56:33 <donri> lontong: so for a real app you probably want to give these tasks some kind of ID and you want to have more than one task, so maybe use a TVar (IntMap a) or something instead
16:59:35 <donri> lontong: if you want persistence look instead at acid-state
16:59:58 <donri> (that is if you want screen captures to survive a server restart)
17:01:38 <lontong> right now i'm using sqlite because i just started programming haskell
17:01:51 <lontong> but yes, i'll be moving to acid-state
17:02:11 <donri> in that case you could do the same with sqlite. instead of putMVar you run an UPDATE query or whatever
17:02:55 <lontong> i tried the sample once and i like how i can use regular haskell data structure
17:05:27 <lontong> i sure have a lot to learn :)
17:47:07 <lontong> donri thanks a lot and good night everyone