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 class
ControlServer.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 void
enterLoop()
void
fileNotFound()
Functions that handle tailing the control file.void
fileRotated()
void
handle(java.lang.Exception e)
void
handle(java.lang.String command)
void
init(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.IOException
ServiceAlreadyStartedException
-
fileNotFound
public void fileNotFound()
Functions that handle tailing the control file.- Specified by:
fileNotFound
in interfaceorg.apache.commons.io.input.TailerListener
-
handle
public void handle(java.lang.String command)
- Specified by:
handle
in interfaceorg.apache.commons.io.input.TailerListener
-
handle
public void handle(java.lang.Exception e)
- Specified by:
handle
in interfaceorg.apache.commons.io.input.TailerListener
-
init
public void init(org.apache.commons.io.input.Tailer tailer)
- Specified by:
init
in interfaceorg.apache.commons.io.input.TailerListener
-
fileRotated
public void fileRotated()
- Specified by:
fileRotated
in interfaceorg.apache.commons.io.input.TailerListener
-
-