diff --git a/gpm.cabal b/gpm.cabal index 099d139..a99648f 100644 --- a/gpm.cabal +++ b/gpm.cabal @@ -2,7 +2,7 @@ -- -- see: https://github.com/sol/hpack -- --- hash: d9338d9561ff06dc6d13e3df5b3985256d508cfa09d153b26fa2eaf00dff864f +-- hash: 04bfdb9ffa855881f6cd6cc09bf3b494a2107ded6cc33c41699546a12526099e name: gpm version: 0.1.0.0 @@ -45,7 +45,6 @@ library , protolude , text , turtle - , unix default-language: Haskell2010 executable gpm @@ -67,5 +66,4 @@ executable gpm , protolude , text , turtle - , unix default-language: Haskell2010 diff --git a/package.yaml b/package.yaml index 2a0cd98..9bd0297 100644 --- a/package.yaml +++ b/package.yaml @@ -32,7 +32,6 @@ dependencies: - protolude - text - turtle -- unix library: source-dirs: src executables: diff --git a/playground/gpm-test.sh b/playground/gpm-test.sh index 273304d..92d67e6 100755 --- a/playground/gpm-test.sh +++ b/playground/gpm-test.sh @@ -36,7 +36,7 @@ subtitle "Cleaning Up" gpm serve stop subtitle "Create Project $testproj" -mkdir $testproj +mkdir -p $testproj pushd $testproj echo "README 1" > README git init . @@ -78,6 +78,9 @@ pushd $testproj2 subtitle "git clone" git clone git://localhost:9418/${prjname}.git $testproj2 +subtitle "gpm init (into the cloned repo)" +gpm init + subtitle "gpm serve stop" gpm serve stop popd diff --git a/src/GPM/Serve.hs b/src/GPM/Serve.hs index d251819..adb0599 100644 --- a/src/GPM/Serve.hs +++ b/src/GPM/Serve.hs @@ -14,7 +14,7 @@ module GPM.Serve where -- | Generic Import -import Protolude hiding (die, stdout, (%), (<.>)) +import Protolude hiding (die, (%), (<.>)) import Turtle -- | Local Imports @@ -23,7 +23,6 @@ import GPM.Helpers (debug, debug_, getGPMDataDir, -- | External Lib Imports import qualified Data.Text as Text -import qualified System.Posix.Process as Process -- | Retrieve a public dir to serve git repositories getPublicDir :: IO Turtle.FilePath @@ -121,18 +120,20 @@ handleProjectDir = getPublicDir >>= putText . format fp dirServe :: Turtle.FilePath -> IO () dirServe pubdir = do - processId <- Process.forkProcess $ - debug_ $ format ("git daemon --reuseaddr --export-all --base-path="%fp%" "%fp) pubdir pubdir gpmDataDir <- getGPMDataDir - inDir gpmDataDir $ do - mktree "procs" - writeTextFile ("procs" "gitServePID") (show processId) + let pidfiledir = gpmDataDir "procs" + debug_ $ + format ("git daemon --detach --pid-file="%fp + %" --reuseaddr --export-all --base-path="%fp%" "%fp) + (pidfiledir "gitServePID") + pubdir + pubdir dirStopServe :: IO () dirStopServe = do gpmDataDir <- getGPMDataDir inDir gpmDataDir $ do - pidtxt <- readTextFile ("procs" "gitServePID") + pidtxt <- readTextFile (gpmDataDir "procs" "gitServePID") if Text.null pidtxt then putErrText "git daemon doesn't appear to be running" else debug_ ("kill " <> pidtxt)