aboutsummaryrefslogtreecommitdiff
path: root/Command/RemoteDaemon.hs
blob: c1741710417c01d1c826862d6414bf89452bec7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{- git-annex command
 -
 - 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" SectionMaintenance
		"persistent communication with remotes"
		paramNothing (run <$$> const parseDaemonOptions)

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