Updated: October 28, 2024 |
System launch and monitor: launch complex applications consisting of many processes that must be started in a specific order
slm [-avV] [-D debug_mode] [-n subsystem_path] [-p priority] [-P search_path] [-r recovery_mode] [-R frequency/sec|min|hour][-s comp_name] [-t polling_interval] [-T total_wait][-x comp_name] config_file
QNX Neutrino
The adoption mechanism works only if the component in the configuration file that corresponds to the running process uses exactly the same arguments (specified using the args element) as the running process and the arguments are in the same order. Otherwise, SLM does not recognize that the component corresponds to the running process.
Set how frequently SLM attempts to recover a component that has terminated abnormally. The frequency argument specifies the maximum number of recovery attempts as an integer and one of the following suffixes, separated by a forward slash: sec (seconds), min (minutes), or hour. For example, 1/min. Default is 2/min (2 times per minute).
The System Launch and Monitor (SLM) service automates the management of complex, multi-process applications that must be started in a specific order.
A configuration file controls SLM's behavior. It specifies the processes to run, their properties, and any interprocess dependencies. You can include other XML files using XML external entities, if needed.
SLM uses the information in the configuration file to internally construct a directed acyclic graph (DAG). SLM uses the DAG to determine the order in which it starts the processes.
Similarly, when a process fails, SLM determines any dependent processes to terminate and restart, when SLM starts the process again.
When you start SLM, you must make sure that slogger2 is running and specify a configuration file, but all the other parameters are optional.
Client applications can control SLM using the slmctl utility or by directly writing commands to the /dev/slm interface. For more information including the control and query commands, see slmctl.
SLM uses an XML configuration file to determine the appropriate order for starting processes. The configuration file lists all the programs for SLM to manage, any dependencies between the programs, the commands for launching the processes, and other properties.
The root XML element of the configuration file is system. All element names start with SLM:, so the root element (and the outline of the file) looks like this:
<SLM:system> -- component and module descriptions -- </SLM:system>
A process managed by SLM is represented by a component. You must provide a component name (usually based on the process name) to use within the configuration file when specifying interprocess dependencies or membership in a module.
All component elements are children of the root element and contain other elements that describe the properties of individual components. The component element uses the following syntax:
<SLM:component name="component_name"> <SLM:ability> ability </SLM:ability> <SLM:args> args </SLM:args> <SLM:cd> directory </SLM:cd> <SLM:command [launch=" launch_option[,launch_option]... "]> executable_path</SLM:command> <SLM:debug> command_args </SLM:debug> <SLM:depend [state="session|stateless"]> component_name </SLM:depend> <SLM:envvar [clear="none|login|all"]> environment_variables </SLM:envvar> <SLM:groups> gid_1[,gid_2]... </SLM:groups> <SLM:partition> partition_name </SLM:partition> <SLM:priority> priority_algorithm </SLM:priority> <SLM:repair> default|none|stop|restart </SLM:repair> <SLM:runmask> component_runmask </SLM:runmask> <SLM:stderr [iomode="w[+]|a[+]"]> filename </SLM:stderr> <SLM:stdin [iomode="r[+]"]> filename </SLM:stdin> <SLM:stdout [iomode="w|a"]> filename </SLM:stdout> <SLM:stop [stop="none|signal"] [child="false|true"] [timeout="timeout_time"]> data </SLM:stop> <SLM:tty> filename </SLM:tty> <SLM:type> type_name </SLM:type> <SLM:user> uid|:gid|uid:gid </SLM:user> <SLM:waitfor [wait="none|delay|pathname|exits|blocks"] [polltime="poll_time:timeout_time"]> data </SLM:waitfor> </SLM:component>
Only the command element is mandatory—all components must have a path to the binary. The remaining elements are optional.
<SLM:ability> ability </SLM:ability>
A procnto ability to give the process. This element is equivalent to the –A option of the on command, and the syntax of the ability specification is the same. Specify an ability element for each required ability.
Using many ability specifications to launch processes is generally a bad idea; using types to configure abilities is simpler and safer.
<SLM:args> args </SLM:args>
If you are specifying arguments for a built-in command, you separate arguments with spaces and sets of arguments with a semi-colon (;). For more information, see the <SLM:command> description.
If the component corresponds to a running process that SLM will adopt as if SLM had launched it (specified by the -a option) make sure that the arguments are identical to the ones the running process uses.
<SLM:cd> directory </SLM:cd>
<SLM:command [launch=" launch_option[ launch_option]... "]> executable_path</SLM:command>
<SLM:args>path1 symlink1; path2 symlink2</SLM:args>The sample configuration files provided below include a component that uses the builtin option.
<SLM:debug> command_args </SLM:debug>
<SLM:depend [state="session|stateless"]> component_name </SLM:depend>
You must define a separate element for each dependency.
SLM won't start a component until all the prerequisites are running and any waitfors are complete.
<SLM:envvar [clear="none|login|all"]> environment_variables </SLM:envvar>
<SLM:groups> gid_1[,gid_2]... </SLM:groups>
<SLM:partition> partition_name </SLM:partition>
<SLM:priority> priority_algorithm </SLM:priority>
<SLM:repair> default|none|stop|restart </SLM:repair>
<SLM:runmask> component_runmask </SLM:runmask>
For example, the decimal value 5 corresponds to the bitmask 00000101, which allows the thread to run on CPUs 0 and 2.
Only specify the runmask once.
A valid runmask is always inherited by children.
For more information about runmasks, see the Multicore Processing chapter of the System Architecture guide, and the Multicore Processing chapter of the QNX Neutrino Programmer's Guide.
<SLM:stderr [iomode="w[+]|a[+]"]> stderr_filename </SLM:stderr>
<SLM:stdin [iomode="r[+]"]> stdin_filename </SLM:stdin>
<SLM:stdout [iomode="w|a"]> stdout_filename </SLM:stdout>
<SLM:stop [stop="none|signal"] [child="false|true"] [timeout="timeout_time"]> stop_data </SLM:stop>
Contains the signal number or name to send the process to stop it. By default, SIGTERM is sent, but you can change this to any signal. Because a signal name does not need to begin with "SIG", all of the following example values are valid:
<SLM:tty> tty_filename </SLM:tty>
<SLM:type> type_name </SLM:type>
<SLM:user> uid|:gid|uid:gid </SLM:user>
<SLM:waitfor [wait="none|delay|pathname|exits|blocks"] [ polltime=poll_time:timeout_time]> waitfor_data </SLM:waitfor>
Use with wait="pathname" or wait="exits" to specify a polling interval and total wait time (both in milliseconds) that override the global values.
For example, polltime="100:20000" results in polling every 100 milliseconds and timing out after 20 seconds.
You can group components into modules. The processes within a module could make up a subsystem or could be used to establish a set of system states, such as a base level of operation and various higher levels. Modules must be named so they can be internally referenced. Each module must be described in an element, as follows:
<SLM:module name="device_monitors"> -- module description -- </SLM:module>
To list the components within a module, use the member element. There are no attributes for member elements; the element values refer to member components by the internal names defined in their respective component elements. Modules cannot contain depend elements.
You can include multiple components in a module by using one member element with wildcards in the component names. For example, you can write:
<SLM:member>devb-*</SLM:member>
Components and modules may be specified in any order in the XML configuration file, but SLM raises an error if any circular dependencies are found.
You can define modules and components for reuse in one or more SLM files. This can be useful for breaking up your SLM modules and components to reuse in different SLM configuration files.
In the SLM configuration file where you are reusing modules and components from other SLM files, you need to define the filenames of where these reusable sections reside. The syntax to do so is as follows:
<!DOCTYPE SLM_system [ <!ENTITY inclusion_name SYSTEM 'filename'> ]>where inclusion_name is a name that you use in your SLM configuration file to identify the reusable entities and filename is a separate file on your system where your reusable SLM modules and components are defined.
At the point in your SLM configuration file where you want to include the reusable entities, include them by specifying the following:
&inclusion_name;
For example, in your system you have a file called my_reusable_modules.xml where you have defined the SLM modules and components that can be included in different SLM configuration files. Then, in one of your SLM configuration files, you can define an entity named reuseModules and later include it:
<!DOCTYPE SLM_system [ <!ENTITY reuseModules SYSTEM 'my_reusable_modules.xml'> ]> ... <SLM:system> ... <!-- Include the contents of what's specified in 'my_reusable_modules.xml' by specifying the entity 'reuseModules' --> &reuseModules; ... </SLM:system>
Suppose you want to automate the setup of your system's IP connectivity. This would require running io-pkt, which creates an IP socket for network traffic, and then running ifconfig to bind an IP address to the socket. You can create a module to include two components that correspond to the two services, and then describe the dependency of ifconfig on io-pkt in the component entries. The XML file would then look like this:
<SLM:system> <SLM:component name="io-pkt"> <SLM:command>/sbin/io-pkt-v6-hc</SLM:command> <SLM:args>-ptcpip stacksize=8192</SLM:args> <SLM:waitfor wait="pathname">/dev/socket</SLM:waitfor> </SLM:component> <SLM:component name="ifconfig"> <SLM:depend>io-pkt</SLM:depend> <SLM:command>/sbin/ifconfig</SLM:command> <SLM:args>en0 192.168.1.5 up</SLM:args> <SLM:waitfor wait="exits"></SLM:waitfor> </SLM:component> <SLM:module name="net-setup"> <SLM:member>io-pkt</SLM:member> <SLM:member>ifconfig</SLM:member> </SLM:module> </SLM:system>
The following example shows how to use SLM to start a shell:
<SLM:component name="console"> <SLM:command launch="session">/bin/ksh</SLM:command> <SLM:args>-l</SLM:args> <SLM:tty>/dev/ser1</SLM:tty> ... </SLM:component>
The following example shows how sshd could be started by SLM (so that sshd could be monitored):
<SLM:component name="sshd"> <SLM:command launch="pathname">/system/xbin/sshd</SLM:command> <SLM:args>-D</SLM:args> ... </SLM:component>
The following example shows how to use the builtin option to call a built-in SLM function (system()) and pass arguments to it using the args element:
<SLM:component name="root-fs"> <SLM:depend>mount-fs</SLM:depend> <SLM:command launch="builtin">system</SLM:command> <SLM:args>setconf _CS_HOSTNAME __HOSTNAME__</SLM:args> </SLM:component>