remotedaemon: Fork to background by default. Added --foreground switch to enable old behavior.

Groundwork for tor hidden services, which the remotedaemon will serve.
This commit is contained in:
Joey Hess 2016-11-20 14:39:26 -04:00
parent d50b0f3bb3
commit a101b8de37
No known key found for this signature in database
GPG key ID: C910D9222512E3C7
8 changed files with 97 additions and 36 deletions

View file

@ -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)
cmd = noCommit $ dontCheck repoExists $
command "remotedaemon" SectionMaintenance
"persistent communication with remotes"
paramNothing (run <$$> const parseDaemonOptions)
seek :: CmdParams -> CommandSeek
seek = withNothing start
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