use --detach of git daemon

This commit is contained in:
Yann Esposito (Yogsototh) 2018-10-21 22:25:08 +02:00
parent f05b8bf6f8
commit 1e8bbcb006
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646
4 changed files with 14 additions and 13 deletions

View file

@ -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

View file

@ -32,7 +32,6 @@ dependencies:
- protolude
- text
- turtle
- unix
library:
source-dirs: src
executables:

View file

@ -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

View file

@ -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)