Service Manager
The servicectl command manages long-running JSH services through a service controller.
It can read service configurations, install or uninstall services, start and stop them,
and inspect current runtime state.
Overview
The servicectl command talks to a running service controller over JSON-RPC.
It does not directly launch services by itself. Instead, it sends management requests such as:
- Read configuration files
- Apply configuration updates
- Install a service from a JSON file or inline options
- Start and stop a service
- Show service status
- Remove a service registration
Controller Address
The command requires a controller endpoint.
You can pass it explicitly with --controller, or provide it through the SERVICE_CONTROLLER
environment variable.
When the servicectl command is launched by the machbase-neo runtime, the runtime sets
SERVICE_CONTROLLER automatically. In normal JSH service-management workflows, you usually do not
need to specify --controller explicitly, so the examples below omit it for readability.
Supported controller address formats are:
host:porttcp://host:portunix://path
Syntax
servicectl [--controller=<addr>] <command> [args...]Common options
-c, --controller <endpoint>controller address in TCP or Unix socket form-t, --timeout <msec>RPC timeout in milliseconds, default5000-h, --helpshow help
Usage example
/work > servicectl statusCommands
The servicectl command supports these subcommands:
readupdatereloadinstall <config.json>install --name <name> --executable <path> [--arg <arg> ...] [--working-dir <dir>] [--enable] [--env KEY=VALUE ...]uninstall <service_name>status [service_name]start <service_name>stop <service_name>details get <service_name> [key] [--format box|json]details set <service_name> <key> <value> [--detail-type <string|number|boolean|bool|object|json>]details delete <service_name> <key>
Service Configuration Format
A service definition is a JSON object.
{
"name": "alpha",
"enable": true,
"working_dir": "/work/app",
"environment": {
"APP_MODE": "prod",
"PORT": "8080"
},
"executable": "server.js",
"args": ["--port", "8080"]
}Common fields are:
| Field | Type | Description |
|---|---|---|
name | String | Service name |
enable | Boolean | Whether the service should be enabled |
working_dir | String | Working directory for the service process |
environment | Object | Environment variables as KEY: VALUE pairs |
executable | String | Executable path or command name |
args | Array<String> | Command-line arguments |
status
Shows either the full service list or one service detail.
Syntax
servicectl status [service_name]When called without a service name, it prints a table with service name, enabled state, runtime status, PID, and executable.
Usage example: list services
/work > servicectl status
┌───────┬─────────┬─────────┬─────┬────────────┐
│ NAME │ ENABLED │ STATUS │ PID │ EXECUTABLE │
├───────┼─────────┼─────────┼─────┼────────────┤
│ alpha │ yes │ running │ 101 │ echo │
│ beta │ no │ stopped │ - │ /bin/date │
└───────┴─────────┴─────────┴─────┴────────────┘With a service name, it prints detailed status including working directory, environment, and recent output lines.
Usage example: one service
/work > servicectl status alpha
[alpha] ENABLED
status: running
exit_code: 0
pid: 55
start: echo [ hello, world ]
cwd: /work
environment:
A=1
B=2
output:
line-6
...
line-25read
Reads service configuration files from the controller configuration directory and reports changes.
Syntax
servicectl readThe result is rendered as a single table. Each row includes a STATUS
column whose value is one of UNCHANGED, ADDED, UPDATED, REMOVED, or ERRORED.
The table is rendered in the same pretty box format used by the servicectl status list output.
Usage example
/work > servicectl read
┌────────┬───────────┬────────────┬──────────────┬─────────────┬────────────┐
│ NAME │ STATUS │ EXECUTABLE │ READ_ERROR │ START_ERROR │ STOP_ERROR │
├────────┼───────────┼────────────┼──────────────┼─────────────┼────────────┤
│ alpha │ UNCHANGED │ echo │ │ │ │
│ beta │ ADDED │ node │ │ │ │
│ old │ REMOVED │ sleep │ │ │ │
│ broken │ ERRORED │ │ invalid json │ │ │
└────────┴───────────┴────────────┴──────────────┴─────────────┴────────────┘update and reload
Both commands ask the controller to apply configuration changes.
updateapplies only the currently detected configuration changes. Added, removed, and updated services are reconciled, while unrelated services are left as-is.reloadrereads configuration files, stops all currently running services first, applies the configuration changes, and then starts only services withenable=true.
Syntax
servicectl update
servicectl reloadThe output contains two sections:
ACTIONS, which lists performed actions such asUPDATE stop,UPDATE start,RELOAD stop, orRELOAD startSERVICES, which shows the resulting service table
install
Installs a service either from a JSON file or from inline options.
After a successful install, the controller writes the service definition to
/etc/services/<name>.json. The file name is determined by the service name
from the JSON file or from the --name option.
Install from JSON file
Syntax
servicectl install <config.json>Usage example
/work > servicectl install svc.jsonIf svc.json contains "name": "alpha", the installed configuration is stored as
/etc/services/alpha.json.
Install with inline options
Syntax
servicectl install \
--name <service_name> \
--executable <path> \
[--working-dir <dir>] \
[--enable] \
[--arg <arg> ...] \
[--env KEY=VALUE ...]Inline install options
-n, --name <name>service name-x, --executable <path>executable path or command name-w, --working-dir <dir>working directory--enableenable the service immediately-a, --arg <arg>add one executable argument, repeatable-e, --env KEY=VALUEadd one environment variable, repeatable
Usage example
/work > servicectl install \
--name svc-inline \
--executable node \
--working-dir /work/app \
--enable \
--arg app.js \
--arg --port \
--arg 8080 \
--env APP_MODE=prod \
--env PORT=8080This inline form also creates /etc/services/svc-inline.json on the controller side.
The command prints a RESULT table and then a detailed SERVICE section.
start and stop
Starts or stops a named service.
Syntax
servicectl start <service_name>
servicectl stop <service_name>The output includes the operation result and the current service state.
Usage example
/work > servicectl start alpha
/work > servicectl stop alphadetails
Manages runtime detail values exposed by a service. These values are separate from the static service configuration and are intended for runtime metadata such as health status, counters, labels, or custom structured state.
Syntax
servicectl details get <service_name> [key] [--format box|json]
servicectl details set <service_name> <key> <value> [--detail-type <string|number|boolean|bool|object|json>]
servicectl details delete <service_name> <key>Details options
--format <box|json>output format fordetails get, defaultbox--detail-type <type>value type fordetails set, defaultstring
Supported detail value types are:
string, the default when--detail-typeis omittednumberbooleanorboolobjectorjson
Type handling rules:
stringstores the input text as-isnumberparses the input as a JSON numberbooleanandboolparse the input as JSONtrueorfalseobjectandjsonparse the input as a JSON object, not an array or scalar
details set uses a single RPC request and behaves as an upsert. If the key already exists,
its value is replaced. If it does not exist, the key is created.
When --format json is used:
servicectl details get <service_name>prints the full details objectservicectl details get <service_name> <key>prints a JSON object containing only that key
Usage example: box output
/work > servicectl details get alpha
DETAILS (3)
┌─────────┬─────────┬────────────────────┐
│ KEY │ TYPE │ VALUE │
├─────────┼─────────┼────────────────────┤
│ enabled │ boolean │ true │
│ labels │ object │ {"tier":"gold"} │
│ retries │ number │ 3 │
└─────────┴─────────┴────────────────────┘Usage example: JSON output
/work > servicectl details get alpha labels --format json
{
"labels": {
"tier": "gold"
}
}Usage example: set values
/work > servicectl details set alpha mode warm
/work > servicectl details set alpha retries 3 --detail-type number
/work > servicectl details set alpha enabled true --detail-type bool
/work > servicectl details set alpha labels '{"tier":"gold"}' --detail-type jsonUsage example: delete a key
/work > servicectl details delete alpha labelsuninstall
Removes a service registration.
Syntax
servicectl uninstall <service_name>Usage example
/work > servicectl uninstall alpha
RESULT
uninstall alpha yes removedTypical Workflow
Create a service JSON file:
{
"name": "alpha",
"enable": true,
"working_dir": "/work",
"executable": "echo",
"args": ["hello", "world"]
}Then manage it with these commands:
/work > servicectl install alpha.json
/work > servicectl status
/work > servicectl stop alpha
/work > servicectl start alpha
/work > servicectl uninstall alphaNotes
servicectlrequires a reachable controller endpoint.statuswithout an argument lists all services; with one argument it shows one service in detail.installcannot mix a config file path with inline install options.- Inline
--envvalues must useKEY=VALUEform. - Relative config file paths are resolved from the current working directory.