Package org.syncany.operations.daemon
Class ControlServer
- java.lang.Object
-
- org.syncany.operations.daemon.ControlServer
-
- All Implemented Interfaces:
org.apache.commons.io.input.TailerListener
public class ControlServer extends java.lang.Object implements org.apache.commons.io.input.TailerListener
The control server watches the daemon control file for changes and reacts on certain commands.Although it is not a real socket, it can be seen as a cross-platform unix-like socket. Due to the nature of the commands in the control file (shutdown/reload), a normal TCP socket is not possible.
The central method is
enterLoop(): This method tails file changes in the daemon control file in the currently active thread. It does not fork a new thread. It blocks and waits for commands until shutdown is received.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classControlServer.ControlCommand
-
Constructor Summary
Constructors Constructor Description ControlServer()ControlServer(java.io.File ctrlFile, org.apache.commons.io.input.Tailer ctrTailer, LocalEventBus eventBus)Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidenterLoop()voidfileNotFound()Functions that handle tailing the control file.voidfileRotated()voidhandle(java.lang.Exception e)voidhandle(java.lang.String command)voidinit(org.apache.commons.io.input.Tailer tailer)
-
-
-
Constructor Detail
-
ControlServer
public ControlServer()
-
ControlServer
@Deprecated public ControlServer(java.io.File ctrlFile, org.apache.commons.io.input.Tailer ctrTailer, LocalEventBus eventBus)
Deprecated.Constructor required for unit testing, as you can inject mocks in this way.
-
-
Method Detail
-
enterLoop
public void enterLoop() throws java.io.IOException, ServiceAlreadyStartedException
- Throws:
java.io.IOExceptionServiceAlreadyStartedException
-
fileNotFound
public void fileNotFound()
Functions that handle tailing the control file.- Specified by:
fileNotFoundin interfaceorg.apache.commons.io.input.TailerListener
-
handle
public void handle(java.lang.String command)
- Specified by:
handlein interfaceorg.apache.commons.io.input.TailerListener
-
handle
public void handle(java.lang.Exception e)
- Specified by:
handlein interfaceorg.apache.commons.io.input.TailerListener
-
init
public void init(org.apache.commons.io.input.Tailer tailer)
- Specified by:
initin interfaceorg.apache.commons.io.input.TailerListener
-
fileRotated
public void fileRotated()
- Specified by:
fileRotatedin interfaceorg.apache.commons.io.input.TailerListener
-
-