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
|
|
|
-
|
|
|
|
- Licensed under the GNU GPL version 3 or higher.
|
|
|
|
-}
|
|
|
|
|
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
|
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 $
|
2016-11-20 18:39:26 +00:00
|
|
|
command "remotedaemon" SectionMaintenance
|
|
|
|
"persistent communication with remotes"
|
|
|
|
paramNothing (run <$$> const parseDaemonOptions)
|
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
|
|
|
|
nullfd <- liftIO $ openFd "/dev/null" ReadOnly Nothing defaultFileFlags
|
|
|
|
liftIO $ daemonize nullfd Nothing False runNonInteractive
|
|
|
|
#else
|
|
|
|
liftIO $ foreground Nothing runNonInteractive
|
|
|
|
#endif
|