Skip to content

Commit

Permalink
allow configuration of unix path
Browse files Browse the repository at this point in the history
  • Loading branch information
Jochen Scheib committed Jul 21, 2023
1 parent 26975e0 commit f74ee43
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ start_moonraker
.pdm.toml
build
dist
.pdm-build
20 changes: 20 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "moonraker/moonraker.py",
"console": "integratedTerminal",
"justMyCode": true,
"args": [
"-c", "moonraker.conf",
"-a", "/tmp/moonraker.sock"
]
}
]
}
29 changes: 29 additions & 0 deletions moonraker.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Sample Moonraker Configuration File
#
# !!! Moonraker does not load this file. See configuration.md !!!
# !!! for details on path to Moonraker's configuration. !!!
#

[server]
# Bind server defaults of 0.0.0.0, port 7125
enable_debug_logging: False

[authorization]
enabled: True
trusted_clients:
# Enter your client IP here or range here
192.168.1.0/24
cors_domains:
# Allow CORS requests for Fluidd
http://app.fluidd.xyz

# Enable OctoPrint compatibility for Slicer uploads
# Supports Cura, Slic3r, and Slic3r dervivatives
# (PrusaSlicer, SuperSlicer)
[octoprint_compat]
# Default webcam config values:
# flip_h = false
# flip_v = false
# rotate_90 = false
# stream_url = /webcam/?action=stream
# webcam_enabled = true
2 changes: 1 addition & 1 deletion moonraker/components/extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ async def start_unix_server(self) -> None:
comms_path = data_path.joinpath("comms")
if not comms_path.exists():
comms_path.mkdir()
sock_path = comms_path.joinpath("moonraker.sock")
sock_path = pathlib.Path(self.server.get_app_args()["api_server"])
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
Expand Down
16 changes: 16 additions & 0 deletions moonraker/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,10 @@ def main(from_package: bool = True) -> None:
parser.add_argument(
"-l", "--logfile", default=None, metavar='<logfile>',
help="log file name and location")
parser.add_argument(
"-a", "--api-server", default=None, metavar='<socketfile>',
help="api server unix domain socket filename"
)
parser.add_argument(
"-n", "--nologfile", action='store_true',
help="disable logging to a file")
Expand Down Expand Up @@ -550,6 +554,18 @@ def main(from_package: bool = True) -> None:
app_args["python_version"] = sys.version.replace("\n", " ")
log_manager = LogManager(app_args, startup_warnings)

# Setup unix socket
if cmd_line_args.api_server:
app_args["api_server"] = os.path.normpath(
os.path.expanduser(cmd_line_args.api_server))
else:
data_path = pathlib.Path(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")
app_args["api_server"] = os.path.normpath(os.path.expanduser(sock_path))

# Start asyncio event loop and server
event_loop = EventLoop()
alt_config_loaded = False
Expand Down

0 comments on commit f74ee43

Please sign in to comment.