2014-04-06 23:06:03 +00:00
|
|
|
{- git-annex command
|
|
|
|
-
|
2016-11-20 18:39:26 +00:00
|
|
|
- Copyright 2014-2016 Joey Hess <id@joeyh.name>
|
2014-04-06 23:06:03 +00:00
|
|
|
-
|
2019-03-13 19:48:14 +00:00
|
|
|
- Licensed under the GNU AGPL version 3 or higher.
|
2014-04-06 23:06:03 +00:00
|
|
|
-}
|
|
|
|
|
2016-11-20 18:39:26 +00:00
|
|
|
{-# LANGUAGE CPP #-}
|
|
|
|
|
2014-04-06 23:06:03 +00:00
|
|
|
module Command.RemoteDaemon where
|
|
|
|
|
|
|
|
import Command
|
|
|
|
import RemoteDaemon.Core
|
2016-11-20 18:39:26 +00:00
|
|
|
import Utility.Daemon
|
2021-05-12 19:08:03 +00:00
|
|
|
import Annex.Path
|
2014-04-06 23:06:03 +00:00
|
|
|
|
2015-07-08 16:33:27 +00:00
|
|
|
cmd :: Command
|
2016-11-20 19:45:01 +00:00
|
|
|
cmd = noCommit $
|
2019-09-30 18:40:46 +00:00
|
|
|
command "remotedaemon" SectionCommon
|
2016-11-20 18:39:26 +00:00
|
|
|
"persistent communication with remotes"
|
2019-09-30 18:40:46 +00:00
|
|
|
paramNothing (run <$$> const (parseDaemonOptions False))
|
2014-04-06 23:06:03 +00:00
|
|
|
|
2016-11-20 18:39:26 +00:00
|
|
|
run :: DaemonOptions -> CommandSeek
|
|
|
|
run o
|
|
|
|
| stopDaemonOption o = error "--stop not implemented for remotedaemon"
|
|
|
|
| foregroundDaemonOption o = liftIO runInteractive
|
|
|
|
| otherwise = do
|
|
|
|
#ifndef mingw32_HOST_OS
|
2021-05-12 19:08:03 +00:00
|
|
|
git_annex <- liftIO programPath
|
|
|
|
ps <- gitAnnexDaemonizeParams
|
|
|
|
let logfd = openFd "/dev/null" ReadOnly Nothing defaultFileFlags
|
|
|
|
liftIO $ daemonize git_annex ps logfd Nothing False runNonInteractive
|
2016-11-20 18:39:26 +00:00
|
|
|
#else
|
|
|
|
liftIO $ foreground Nothing runNonInteractive
|
|
|
|
#endif
|