2019-05-31 00:24:14 +03:00
|
|
|
module Main where
|
|
|
|
|
|
|
|
import ClassyPrelude
|
2019-07-16 03:01:45 +03:00
|
|
|
|
|
|
|
import Noun
|
2019-05-31 00:24:14 +03:00
|
|
|
import Vere.Pier.Types
|
2019-07-16 03:01:45 +03:00
|
|
|
import Vere.Pier
|
|
|
|
import Vere.Serf
|
|
|
|
|
2019-07-16 05:20:23 +03:00
|
|
|
import Control.Concurrent (threadDelay)
|
|
|
|
import System.Directory (removeFile)
|
|
|
|
import Text.Show.Pretty (pPrint)
|
2019-06-25 04:10:41 +03:00
|
|
|
|
|
|
|
import qualified Vere.Log as Log
|
|
|
|
import qualified Vere.Persist as Persist
|
|
|
|
import qualified Vere.Pier as Pier
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
2019-05-31 00:24:14 +03:00
|
|
|
|
|
|
|
main :: IO ()
|
|
|
|
main = do
|
2019-07-17 02:26:47 +03:00
|
|
|
let pillPath = "/home/benjamin/r/urbit/bin/brass.pill"
|
2019-07-16 05:20:23 +03:00
|
|
|
shipPath = "/home/benjamin/r/urbit/zod/"
|
|
|
|
ship = 0 -- zod
|
2019-07-16 03:01:45 +03:00
|
|
|
|
2019-07-16 05:20:23 +03:00
|
|
|
removeFile (shipPath <> ".urb/chk/north.bin")
|
|
|
|
removeFile (shipPath <> ".urb/chk/south.bin")
|
2019-06-25 04:10:41 +03:00
|
|
|
|
2019-07-16 05:20:23 +03:00
|
|
|
(s,l,e,m) <- Pier.boot pillPath shipPath ship
|
|
|
|
print (e,m)
|
|
|
|
threadDelay 500000
|
|
|
|
kill s
|
|
|
|
putStrLn "Booted!"
|
|
|
|
|
|
|
|
removeFile (shipPath <> ".urb/chk/north.bin")
|
|
|
|
removeFile (shipPath <> ".urb/chk/south.bin")
|
|
|
|
|
|
|
|
(s,l,e,m) <- Pier.resume shipPath
|
|
|
|
print (e,m)
|
|
|
|
putStrLn "Resumed!"
|
2019-06-25 04:10:41 +03:00
|
|
|
|
2019-07-16 03:01:45 +03:00
|
|
|
pure ()
|
2019-06-25 04:10:41 +03:00
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
tryCopyLog :: IO ()
|
|
|
|
tryCopyLog = do
|
|
|
|
let logPath = "/Users/erg/src/urbit/zod/.urb/falselog/"
|
2019-05-31 02:04:06 +03:00
|
|
|
falselogPath = "/Users/erg/src/urbit/zod/.urb/falselog2/"
|
2019-05-31 00:24:14 +03:00
|
|
|
|
2019-06-25 04:10:41 +03:00
|
|
|
----------------------------------------
|
|
|
|
|
|
|
|
persistQ <- newTQueueIO
|
|
|
|
releaseQ <- newTQueueIO
|
|
|
|
log <- Log.open logPath
|
|
|
|
persist <- Persist.start log persistQ (writeTQueue releaseQ)
|
|
|
|
ident <- Log.readIdent log
|
2019-05-31 00:24:14 +03:00
|
|
|
|
2019-06-25 04:10:41 +03:00
|
|
|
----------------------------------------
|
2019-05-31 00:24:14 +03:00
|
|
|
|
2019-06-25 04:10:41 +03:00
|
|
|
lastEv <- Log.latestEventNumber log
|
|
|
|
events <- Log.readEvents log 1 3142
|
2019-05-31 00:24:14 +03:00
|
|
|
|
2019-06-25 04:10:41 +03:00
|
|
|
----------------------------------------
|
2019-05-31 00:24:14 +03:00
|
|
|
|
2019-06-25 04:10:41 +03:00
|
|
|
print ident
|
|
|
|
print lastEv
|
|
|
|
print (length events)
|
2019-05-31 00:24:14 +03:00
|
|
|
|
2019-06-25 04:10:41 +03:00
|
|
|
----------------------------------------
|
|
|
|
|
|
|
|
persistQ2 <- newTQueueIO
|
|
|
|
releaseQ2 <- newTQueueIO
|
|
|
|
log2 <- Log.open falselogPath
|
|
|
|
persist2 <- Persist.start log2 persistQ2 (writeTQueue releaseQ2)
|
|
|
|
|
|
|
|
----------------------------------------
|
|
|
|
|
|
|
|
Log.writeIdent log2 ident
|
2019-05-31 02:04:06 +03:00
|
|
|
|
2019-05-31 00:24:14 +03:00
|
|
|
let writs = events <&> \(id, a) ->
|
2019-06-25 04:10:41 +03:00
|
|
|
Writ id Nothing (Jam a) []
|
|
|
|
|
|
|
|
----------------------------------------
|
2019-05-31 00:24:14 +03:00
|
|
|
|
|
|
|
print "About to write"
|
2019-06-25 04:10:41 +03:00
|
|
|
|
|
|
|
for_ writs $ \w ->
|
|
|
|
atomically (writeTQueue persistQ2 w)
|
|
|
|
|
|
|
|
----------------------------------------
|
2019-05-31 00:24:14 +03:00
|
|
|
|
|
|
|
print "About to wait"
|
|
|
|
|
2019-06-25 04:10:41 +03:00
|
|
|
replicateM_ 100 $ do
|
|
|
|
atomically $ readTQueue releaseQ2
|
|
|
|
|
|
|
|
----------------------------------------
|
|
|
|
|
2019-05-31 00:24:14 +03:00
|
|
|
print "Done"
|