| Home | Internal Documentation |
Libraries: Mug · ThorsMug · ThorsSlack · NisseServer · NisseHTTP · ThorsSocket · ThorsCrypto · ThorsSerializer · ThorsMongo · ThorsLogging · ThorsIOUtil
A configurable HTTP server application that dynamically loads shared-library plugins at runtime. Define your REST endpoints as plugins and Mug handles the server lifecycle, JSON configuration, TLS setup, and hot-reloading of plugins.
Namespace: ThorsAnvil::ThorsMug
Mug is a standalone executable built on NisseServer and NisseHTTP. Instead of writing a custom main() function, you:
MugPlugin.mug binary – it loads your plugins and starts serving.This architecture enables hot-reloading: Mug periodically checks if plugin libraries have been updated and reloads them without restarting the server.
mug --config /path/to/config.json
| Flag | Description |
|---|---|
--config <file> |
Path to the JSON configuration file |
--silent |
Run in headless mode (no interactive output) |
--help |
Display usage information |
--log-file <path> |
Add a log file |
--log-sys <name> |
Enable system logging |
--log-level <level> |
Set log verbosity |
If --config is not specified, Mug searches default paths for a configuration file.
The configuration is a JSON file:
{
"controlPort": 8079,
"libraryCheckTime": 5000,
"servers": [
{
"port": 8080,
"actions": [
{
"pluginPath": "/path/to/libMyPlugin.so",
"config": { "key": "value" }
}
]
},
{
"port": 8443,
"certPath": "/etc/letsencrypt/live/example.com",
"actions": [
{
"pluginPath": "/path/to/libSecurePlugin.so",
"config": {}
}
]
}
]
}
| Field | Type | Default | Description |
|---|---|---|---|
controlPort |
int | 8079 | Port for the HTTP control endpoint (stop/ping) |
libraryCheckTime |
int | 0 | How often to check for plugin updates (ms). 0 = disabled. |
servers |
array | required | List of port configurations |
| Field | Type | Description |
|---|---|---|
port |
int | Port to listen on |
certPath |
string (optional) | Path to TLS certificate directory (containing fullchain.pem and privkey.pem) |
actions |
array | Plugins to load for this port |
| Field | Type | Description |
|---|---|---|
pluginPath |
string | Path to the shared library (.so / .dylib) |
config |
object | Arbitrary JSON passed to the plugin’s factory function |
Mug exposes an HTTP control endpoint on controlPort. Send requests to manage the server:
# Graceful shutdown
curl "http://localhost:8079/control?command=stopsoft"
# Immediate shutdown
curl "http://localhost:8079/control?command=stophard"
# Health check
curl "http://localhost:8079/control?command=ping"
When libraryCheckTime is non-zero, Mug periodically checks if any plugin shared libraries have been modified on disk. If a library has been updated:
MugPlugin::stop() is called).MugPlugin::start() is called).This enables zero-downtime updates to your HTTP handlers.