Class SpawnService
- Since:
- 1
- Version:
- 1
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddDaemon(SpawnProcess process) Add a daemon process to the local node.voidaddDaemon(SpawnProcess process, NodeId nodeId) Add a daemon process to the specified node.voidaddProcess(SpawnProcess process) Add a process to the spawn list of the local node.voidaddProcess(SpawnProcess process, NodeId nodeId) Add a process to the spawn list of the specified node.Return a list of daemon processes that are currently expected to be running on the local node.getDaemons(NodeId nodeId) Return a list of daemon processes that are currently expected to be running on the specified node.voidremoveProcess(SpawnProcess process) Remove a process from the spawn list.voidrestartDaemon(SpawnProcess process) Restart the specified daemon process.voidsetPriority(SpawnProcess process, int priority) Set the priority of the specified process.
-
Method Details
-
addProcess
Add a process to the spawn list of the specified node. 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. If thedaemonflag of the process is true, this will be run as a daemon. If the flag is false, the process will be run once.A
SpawnProcessobject can only be used once as it will be updated with lifecycle and end state data. Trying to add the same object multiple times will throw an exception.As the process is queued until the native spawner becomes available, this is a convenient way of ensuring a native program is run as soon as possible without needing to monitor the connectivity state of native spawner.
While daemons can be started with this api, consider using
addDaemon()instead as this will also ensure that the daemon flag is set on the process.- Parameters:
process- the process that should be runnodeId- the node to run the process on- Since:
- 1
-
addDaemon
Add a daemon process to the specified node. Daemons are processes that are long running and should be restarted if they crash. This method will set the daemon flag of the specified process, ensuring that all processes started with this method are in fact daemons.A
SpawnProcessobject can only be used once as it will be updated with lifecycle and end state data. Trying to add the same object multiple times will throw an exception. In the case of a daemon, the pid, end state and lifecycle events will change as the process is restarted.- Parameters:
process- the process that should be run as a daemonnodeId- the node to run the process on- Since:
- 10
-
addProcess
Add a process to the spawn list of the local node. 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. If thedaemonflag of the process is true, this will be run as a daemon. If the flag is false, the process will be run once.A
SpawnProcessobject can only be used once as it will be updated with lifecycle and end state data. Trying to add the same object multiple times will throw an exception.As the process is queued until the native spawner becomes available, this is a convenient way of ensuring a native program is run as soon as possible without needing to monitor the connectivity state of native spawner.
While daemons can be started with this api, consider using
addDaemon()instead as this will also ensure that the daemon flag is set on the process.- Parameters:
process- the process that should be run- Since:
- 1
-
addDaemon
Add a daemon process to the local node. Daemons are processes that are long running and should be restarted if they crash. This method will set the daemon flag of the specified process, ensuring that all processes started with this method are in fact daemons.A
SpawnProcessobject can only be used once as it will be updated with lifecycle and end state data. Trying to add the same object multiple times will throw an exception. In the case of a daemon, the pid, end state and lifecycle events will change as the process is restarted.- Parameters:
process- the process that should be run as a daemon- Since:
- 10
-
removeProcess
Remove a process from the spawn list. If it is running, it will be killed. This is typically used to remove daemon processes that are no longer needed. If the process is not a daemon process, it will still be killed if currently running.This is equivalent to calling
SpawnProcess.remove().- Parameters:
process- the process to remove- Since:
- 1
-
restartDaemon
Restart the specified daemon process. This kills the process and allows the service to restart it. This can be used to reset a daemon that is not performing correctly.This equivalent to calling
SpawnProcess.restart().- Parameters:
process- the process to restart- Since:
- 1
-
setPriority
Set the priority of the specified process.This is equivalent to calling
SpawnProcess.setPriority().- Parameters:
process- the process to change the priority ofpriority- the new priority -20..19 (unix semantics)- Since:
- 1
-
getDaemons
Return a list of daemon processes that are currently expected to be running on the specified node.- Parameters:
nodeId- id of the node to return the list from- Returns:
- list of processes
- Since:
- 10
-
getDaemons
Return a list of daemon processes that are currently expected to be running on the local node.- Returns:
- list of processes
- Since:
- 10
-