33 Commits

Author SHA1 Message Date
Eric Callahan
0a8590643f
server: refactor startup
Use asyncio.run() to launch the server application as recommended
by the Python docs.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-08-08 16:29:01 -04:00
Eric Callahan
9097cfcce7 klippy_connection: store klipper source path and python path
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-07-24 16:35:37 -04:00
Eric Callahan
0ff1d79b5b server: improve add_warning method
Add an exc_info parameter that optionally takes an
exception that is passed to the logging function. This
will log the traceback without an additional logging call.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-07-24 07:37:08 -04:00
Eric Callahan
3f62bb6fb4 database: add backup, restore, and compact endpoints
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-05-21 06:18:46 -04:00
Eric Callahan
8d59c424d7 server: convert history a core component
The history component requires no specific configuration, is
generally always used, and has no dependencies that prevent
loading at startup.  Convert history to a core component,
making it eligible for lookup/use in optional components.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-05-03 08:22:41 -04:00
Eric Callahan
d6c8d6d3a6
server: add method to get individual app args
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-02-01 10:27:20 -05:00
Eric Callahan
088a7e4e70
server: create a misc folder in the datapath
This folder contains miscellaneous files used by Moonraker
or other applications in the Klipper ecosystem.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-02-01 10:27:20 -05:00
Eric Callahan
bc18e3174a
server: load "authorization" as a core component
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-28 05:42:22 -05:00
Eric Callahan
ddd735feba
refactor: convert klippy_connection into a component
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-13 15:15:15 -05:00
Eric Callahan
a88468eb79
refactor: convert websockets into a component
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-13 15:15:15 -05:00
Eric Callahan
d506c9241f
refactor: convert application into a component
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2024-01-13 15:15:14 -05:00
Eric Callahan
94b1896e28
server: add support for python dependency recovery
It is possible that older versions of Moonraker's update_manager
will fail in its attempt to update python packages.  This can lead
to missing modules when the new version of Moonraker is loaded.

When a `ModuleNotFound` error is received during a call to
"load_component" Moonraker will attempt to install its
missing dependencies.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2024-01-13 15:15:14 -05:00
Eric Callahan
ca595163bb
server: log launch arguments:
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-29 20:13:29 -05:00
Eric Callahan
5585884d26
app: resolve soft restart issues
Clear the API cache when closing to purge stale callbacks.  In addition,
explicitly delte the server object after the eventloop stops.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-29 08:22:50 -05:00
Eric Callahan
bfeb096f31
jsonrpc: share one instance among all transports
This change refactors the APIDefiniton into a dataclass, allowing
defs to be shared directly among HTTP and RPC requests.  In
addition, all transports now share one instance of JSONRPC,
removing duplicate registration.  API Defintiions are registered
with the RPC Dispatcher, and it validates the Transport type.
In addition tranports may perform their own validation prior
to request execution.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-16 16:21:21 -05:00
Eric Callahan
8b2d9b26f5
app: streamline endpoint registration
Refactor endpoint registration to reduce duplicated code.
Rename some APIDefinition attributes for clarity.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-16 16:21:21 -05:00
Eric Callahan
7de61eb113
klippy_connection: track connection state with an enum
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-16 16:21:21 -05:00
Eric Callahan
b18e9cc222
all: Replace strings with RequestType flags
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-12-16 16:21:20 -05:00
Eric Callahan
27dddd62ac
extensions: support agent method registration
Create a websocket endpoint that allows clients identified as
agents to register remote methods with Klipper.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-11-07 11:27:11 -05:00
Eric Callahan
ddd4a02e9c
server: fix linter errors
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-10-07 10:30:08 -04:00
Eric Callahan
51f4d4b888
eventloop: add support for uvloop
Signed-off-by:  Eric Callahan <arskine.code@gmail.com>
2023-10-06 18:20:28 -04:00
Eric Callahan
f99e5b0bea
utils: add support for msgspec with stdlib json fallback
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2023-10-06 18:20:28 -04:00
Eric Callahan
a0a50442f7
server: add support for enironment variables
Allow all command line arguments to be specificed as an
environment variable.  If both the command line argument
and environment variable is present the command line argument
takes precedence.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-07-25 16:27:11 -04:00
Eric Callahan
1fadae885e
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>
2023-07-22 06:17:56 -04:00
Eric Callahan
ac876b9271
server: bump API version to 1.3.0
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-07-15 16:15:45 -04:00
Eric Callahan
f6770e2865
server: improve event exception handling
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-06-26 16:48:48 -04:00
Eric Callahan
02d66a346d
server: add support for instance uuids
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-06-21 11:03:07 -04:00
Eric Callahan
cd4fdfb7b6
utils: report additional git repo data
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-05-26 10:49:58 -04:00
Eric Callahan
6d73c60a38
moonraker: move common classes to common.py
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-24 07:08:41 -05:00
Eric Callahan
a02209443e
server: remove duplicates when loading components
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-22 18:08:51 -05:00
Eric Callahan
2cda75ff2c
utils: simplify sentinel object
Use an enum to represent the sentinel rather than a singleton object.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-22 18:08:50 -05:00
Eric Callahan
b9a17e07e9
moonraker: convert code to a package
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-22 12:16:26 -05:00
Eric Callahan
a5d63db9a6
server: rename moonraker.py to server.py
Signed-off-by:  Eric Callahan <arksiine.code@gmail.com>
2023-02-21 18:05:01 -05:00