The command line: opensmi-ros2 serve machine.toml and python -m opensmi.ros2.
Both call main, which reads the file with ~opensmi.ros2.server.loader.load_machine,
builds opensmi's Server, adds the Machine and serves until Ctrl+C or SIGTERM.
opensmi-ros2 serve machine.toml opensmi-ros2 serve machine.toml --server-config other-server.toml
rclpy is imported only once the whole file has been validated, so --help and a file with mistakes work on a machine without ROS2.
[server] config = "server.toml" in the machine file and --server-config PATH point to an opensmi server configuration (endpoint, users, logging). The command line wins. A path in the file is relative to the file, a path on the command line to the working directory.
Exit status: 0 after a clean stop, 1 when the file or a configuration cannot be used (each mistake is printed to stderr, one per line, and nothing has been started), 2 for a command line argparse refuses.
| Function | main |
Run the command line and return its exit status. |
| Async Function | serve |
Serve a Machine in an opensmi Server until stop is set, then shut the server down. |
| Constant | PROG |
Undocumented |
| Exception | _ |
Something the user gave cannot be used; the message is what to tell them. |
| Function | _parser |
Undocumented |
| Function | _refuse |
Say on stderr why nothing was started, and return the exit status for it. |
| Function | _require |
Refuse a --server-config that is not a file, before anything is built. |
| Async Function | _run |
Serve until SIGINT or SIGTERM, where the loop can listen for them. |
Sequence[ str] | None = None, *, runtime_factory: Callable[ [ ROS2Config], RuntimeInterface] | None = None) -> int:
¶
Run the command line and return its exit status.
| Parameters | |
argv:Sequence[ | The arguments after the program name; None reads sys.argv. |
runtimeCallable[ | Passed to load_machine; None builds the real Runtime, which needs rclpy. A test passes one that returns its fake. |
| Returns | |
int | Undocumented |
Serve a Machine in an opensmi Server until stop is set, then shut the server down.
| Parameters | |
machine:ConfiguredMachine | The Machine to serve. |
serverPath | None | An opensmi server configuration file, or None for opensmi's defaults. |
stop:asyncio.Event | Set to ask for a clean stop. Cancelling the task stops it as well. |
| Raises | |
_UnusableError | When the server configuration cannot be read. |