Package com.tccc.kos.core.service.spawn
Class SpawnService
java.lang.Object
com.tccc.kos.commons.util.ready.ReadyBean
com.tccc.kos.commons.core.service.AbstractService
com.tccc.kos.core.service.spawn.SpawnService
- All Implemented Interfaces:
CtxEventListener
,BinaryMsgIfaceFactory
,ContextHandleAware
,HandleAware
,Ready
,ReadyListener
Service that is used to start/stop native programs on this node or other
nodes using a spawn session. All programs started by this service are
monitored and will be restarted using a backoff algorithm if they crash.
This is the preferred way to start long-running programs on the current
node or nodes that don't run Java.
- Since:
- 1.0
- Version:
- 2023-03-06
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addProcess
(SpawnProcess process) Add a process to the spawn list.void
addProcess
(SpawnProcess process, NodeId nodeId) Add a process to the spawn list.getIface
(String name, BinaryMsgSession session) Given the name of an interface from a BinaryMsgSession, return an instance of BinaryMsgIface or null.getProcesses
(NodeId nodeId) Return a list of processes that are currently expected to be running on the specified node.void
removeProcess
(SpawnProcess process) Remove a process from the spawn list.void
restartProcess
(SpawnProcess process) Restart the specified process.void
setPriority
(SpawnProcess process, int priority) Set the priority of the specified process.Methods inherited from class com.tccc.kos.commons.core.service.AbstractService
getHandle, getHandlePrefix
Methods inherited from class com.tccc.kos.commons.util.ready.ReadyBean
getReady, onBeanReady, onDependenciesReady
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.tccc.kos.commons.core.context.CtxEventListener
onCtxAutowiringCompleted, onCtxDestroyed, onCtxPhaseCompleted
Methods inherited from interface com.tccc.kos.commons.core.service.handle.HandleAware
addHandleChild, getName, getPath
Methods inherited from interface com.tccc.kos.commons.util.ready.ReadyListener
onDependenciesGroupReady
-
Method Details
-
addProcess
Add a process to the spawn list. If there is already an iface to the node then the process will be started immediately, otherwise it will start once the iface is established.- Parameters:
process
- the process that should be runnodeId
- the node to run the process on
-
addProcess
Add a process to the spawn list. If there is already an iface to the node then the process will be started immediately, otherwise it will start once the iface is established. This will be run on the local node.- Parameters:
process
- the process that should be run
-
removeProcess
Remove a process from the spawn list. If it is running, it will be killed.- Parameters:
process
- the process to remove
-
restartProcess
Restart the specified process. This kills the process and allows the service to restart it.- Parameters:
process
- the process to restart
-
setPriority
Set the priority of the specified process.- Parameters:
process
- the process to change the priority ofpriority
- the new priority -20..19 (unix semantics)
-
getProcesses
Return a list of processes that are currently expected to be running on the specified node.- Returns:
- list of processes
-
getIface
Description copied from interface:BinaryMsgIfaceFactory
Given the name of an interface from a BinaryMsgSession, return an instance of BinaryMsgIface or null.- Specified by:
getIface
in interfaceBinaryMsgIfaceFactory
- Parameters:
name
- the name of the interfacesession
- the session to back the interface- Returns:
- the iface or null
-