Application Manager Client
App Manager Client
Provides API for managing application containers: - Install, start, stop, uninstall applications - Get application info and stats - Stream application logs
- class neoruntime_ipc_sdk.app.AppInfo(id, name, version, state, container_id, pid, installed_at, started_at, stopped_at, restart_count, manifest_path, instance_path)[source]
Bases:
objectApplication information
- __init__(id, name, version, state, container_id, pid, installed_at, started_at, stopped_at, restart_count, manifest_path, instance_path)
- class neoruntime_ipc_sdk.app.AppStats(app_id, cpu_usage_percent, memory_usage_bytes, memory_limit_bytes, thread_count, uptime_seconds)[source]
Bases:
objectApplication runtime statistics
- __init__(app_id, cpu_usage_percent, memory_usage_bytes, memory_limit_bytes, thread_count, uptime_seconds)
- class neoruntime_ipc_sdk.app.LogLine(timestamp, level, message)[source]
Bases:
objectSingle log line
- __init__(timestamp, level, message)
- class neoruntime_ipc_sdk.app.AppClient(endpoint=None)[source]
Bases:
GrpcClientApplication Container Management Client
Usage:
app_client = AppClient() # List all apps apps = app_client.list_apps() for app in apps: print(f"{app.name}: {app.state}") # Get logs (last 100 lines) for line in app_client.get_logs("my_app", max_lines=100): print(line) # Follow logs in real-time for line in app_client.get_logs("my_app", follow=True): print(line)
- register_web_url(path='/')[source]
Register a web access path for this app.
After calling this method, the web console will show a “Visit App” button linking to
http://{device_ip}:{inbound_port}{path}.Requires the
APP_IDenvironment variable to be set (injected automatically by the platform when the container starts).- Parameters:
path (str) – Web page path, default
"/"
- restart_app(app_id, timeout_seconds=30)[source]
Restart a running application (stop + start).
This is a composite operation since the gRPC service does not expose a dedicated RestartApp RPC. It stops the app and then starts it again.
- get_logs(app_id, max_lines=100, follow=False)[source]
Get application logs
- Parameters:
- Yields:
LogLine objects
Examples
# Get last 100 lines for line in app_client.get_logs("my_app", max_lines=100): print(line) # Follow logs in real-time for line in app_client.get_logs("my_app", follow=True): print(line)
Usage Examples
Application Lifecycle
from neoruntime_ipc_sdk import AppClient
app = AppClient()
# List all applications
apps = app.list_apps()
for a in apps:
print(f"{a.name}: {a.state}")
# Install application
app_id = app.install_app(
manifest_path="/data/apps/my_app/app.yaml",
image_path="/data/apps/my_app/image.tar"
)
# Start application
app.start_app(app_id)
# Restart application (stop + start)
app.restart_app(app_id, timeout_seconds=30)
# Stop application
app.stop_app(app_id)
# Uninstall application
app.uninstall_app(app_id, keep_logs=True)
Getting Application Info
# Get application details
info = app.get_app("my_app")
print(f"Name: {info.name}")
print(f"Version: {info.version}")
print(f"State: {info.state}")
# Get application statistics
stats = app.get_app_stats("my_app")
print(f"CPU: {stats.cpu_usage_percent}%")
print(f"Memory: {stats.memory_usage_bytes / 1024 / 1024:.1f} MB")
Viewing Application Logs
# Get last 100 log lines
for line in app.get_logs("my_app", max_lines=100):
print(line)
# Follow logs in real-time
for line in app.get_logs("my_app", follow=True):
print(line)
# Get text-formatted logs
for text in app.get_logs_text("my_app"):
print(text)
Registering Web URL
# Register web access path (inside app container)
# Requires APP_ID environment variable (injected by platform)
app.register_web_url("/")
# Register custom path
app.register_web_url("/dashboard")
Context Manager
with AppClient() as app:
apps = app.list_apps()
for a in apps:
print(f"{a.name}: {a.state}")