aboutsummaryrefslogtreecommitdiff
path: root/Command
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-11-20 14:39:26 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-11-20 14:50:36 -0400
commit8e28135b26db1c920ebde7438db9bad87d3026ee (patch)
tree68d948ce454ea0661dbf11416d3e26182e3447af /Command
parent513d36ae4de0be74b12112487d8e1b12b7c7f43e (diff)
remotedaemon: Fork to background by default. Added --foreground switch to enable old behavior.
Groundwork for tor hidden services, which the remotedaemon will serve.
Diffstat (limited to 'Command')
-rw-r--r--Command/EnableTor.hs2
-rw-r--r--Command/RemoteDaemon.hs31
2 files changed, 20 insertions, 13 deletions
diff --git a/Command/EnableTor.hs b/Command/EnableTor.hs
index 1a54c6c5d..369ea7509 100644
--- a/Command/EnableTor.hs
+++ b/Command/EnableTor.hs
@@ -14,7 +14,7 @@ import Utility.Tor
-- git-annex, as that would create root-owned files.
cmd :: Command
cmd = noCommit $ dontCheck repoExists $
- command "enable-tor" SectionPlumbing ""
+ command "enable-tor" SectionSetup ""
"userid uuid" (withParams seek)
seek :: CmdParams -> CommandSeek
diff --git a/Command/RemoteDaemon.hs b/Command/RemoteDaemon.hs
index 7c7ecef4b..c68cf816a 100644
--- a/Command/RemoteDaemon.hs
+++ b/Command/RemoteDaemon.hs
@@ -1,25 +1,32 @@
{- git-annex command
-
- - Copyright 2014 Joey Hess <id@joeyh.name>
+ - Copyright 2014-2016 Joey Hess <id@joeyh.name>
-
- Licensed under the GNU GPL version 3 or higher.
-}
+{-# LANGUAGE CPP #-}
+
module Command.RemoteDaemon where
import Command
import RemoteDaemon.Core
+import Utility.Daemon
cmd :: Command
-cmd = noCommit $
- command "remotedaemon" SectionPlumbing
- "detects when remotes have changed, and fetches from them"
- paramNothing (withParams seek)
-
-seek :: CmdParams -> CommandSeek
-seek = withNothing start
+cmd = noCommit $ dontCheck repoExists $
+ command "remotedaemon" SectionMaintenance
+ "persistent communication with remotes"
+ paramNothing (run <$$> const parseDaemonOptions)
-start :: CommandStart
-start = do
- liftIO runForeground
- stop
+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