server: allow commandline unix socket configuration
Add a command line option that allows the installation to specify the exact path to Moonraker's unix domain server socket. The default location remains at: <data_path>/comms/moonraker.sock Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
fdc3e0eb0b
commit
1fadae885e
|
@ -113,15 +113,18 @@ class ExtensionManager:
|
|||
return await conn.call_method(method, args)
|
||||
|
||||
async def start_unix_server(self) -> None:
|
||||
data_path = pathlib.Path(self.server.get_app_args()["data_path"])
|
||||
comms_path = data_path.joinpath("comms")
|
||||
if not comms_path.exists():
|
||||
comms_path.mkdir()
|
||||
sock_path = comms_path.joinpath("moonraker.sock")
|
||||
sockfile: str = self.server.get_app_args()["unix_socket_path"]
|
||||
sock_path = pathlib.Path(sockfile).expanduser().resolve()
|
||||
logging.info(f"Creating Unix Domain Socket at '{sock_path}'")
|
||||
self.uds_server = await asyncio.start_unix_server(
|
||||
self.on_unix_socket_connected, sock_path, limit=UNIX_BUFFER_LIMIT
|
||||
)
|
||||
try:
|
||||
self.uds_server = await asyncio.start_unix_server(
|
||||
self.on_unix_socket_connected, sock_path, limit=UNIX_BUFFER_LIMIT
|
||||
)
|
||||
except asyncio.CancelledError:
|
||||
raise
|
||||
except Exception:
|
||||
logging.exception(f"Failed to create Unix Domain Socket: {sock_path}")
|
||||
self.uds_server = None
|
||||
|
||||
def on_unix_socket_connected(
|
||||
self, reader: asyncio.StreamReader, writer: asyncio.StreamWriter
|
||||
|
|
|
@ -484,10 +484,14 @@ def main(from_package: bool = True) -> None:
|
|||
)
|
||||
parser.add_argument(
|
||||
"-c", "--configfile", default=None, metavar='<configfile>',
|
||||
help="Location of moonraker configuration file")
|
||||
help="Path to Moonraker's configuration file")
|
||||
parser.add_argument(
|
||||
"-l", "--logfile", default=None, metavar='<logfile>',
|
||||
help="log file name and location")
|
||||
help="Path to Moonraker's log file")
|
||||
parser.add_argument(
|
||||
"-u", "--unixsocket", default=None, metavar="<unixsocket>",
|
||||
help="Path to Moonraker's unix domain socket"
|
||||
)
|
||||
parser.add_argument(
|
||||
"-n", "--nologfile", action='store_true',
|
||||
help="disable logging to a file")
|
||||
|
@ -525,6 +529,13 @@ def main(from_package: bool = True) -> None:
|
|||
cfg_file: str = cmd_line_args.configfile
|
||||
else:
|
||||
cfg_file = str(data_path.joinpath("config/moonraker.conf"))
|
||||
if cmd_line_args.unixsocket is not None:
|
||||
unix_sock: str = cmd_line_args.unixsocket
|
||||
else:
|
||||
comms_dir = data_path.joinpath("comms")
|
||||
if not comms_dir.exists():
|
||||
comms_dir.mkdir()
|
||||
unix_sock = str(comms_dir.joinpath("moonraker.sock"))
|
||||
app_args = {
|
||||
"data_path": str(data_path),
|
||||
"is_default_data_path": cmd_line_args.datapath is None,
|
||||
|
@ -535,7 +546,8 @@ def main(from_package: bool = True) -> None:
|
|||
"asyncio_debug": cmd_line_args.asyncio_debug,
|
||||
"is_backup_config": False,
|
||||
"is_python_package": from_package,
|
||||
"instance_uuid": instance_uuid
|
||||
"instance_uuid": instance_uuid,
|
||||
"unix_socket_path": unix_sock
|
||||
}
|
||||
|
||||
# Setup Logging
|
||||
|
|
Loading…
Reference in New Issue