docs: document script hot-reload mechanisms for all script types
This commit is contained in:
@@ -38,6 +38,7 @@ Both central and site clusters. Each side has communication actors that handle m
|
||||
- **Pattern**: Broadcast with per-site acknowledgment (deploy to all sites), or targeted to a single site (per-site deployment).
|
||||
- When shared scripts, external system definitions, database connections, data connections, notification lists, or SMTP configuration are explicitly deployed, central sends them to the target site(s).
|
||||
- Each site acknowledges receipt and reports success/failure independently.
|
||||
- **Shared script deployment triggers immediate recompilation on the site** — the site's `SharedScriptLibrary` replaces its in-memory compiled code, making updated shared scripts available to all running instances without redeployment. Other artifact types (external systems, database connections, etc.) are stored but do not require recompilation.
|
||||
|
||||
### 4. Integration Routing (External System → Central → Site → Central → External System)
|
||||
- **Pattern**: Request/Response (brokered).
|
||||
|
||||
@@ -99,6 +99,21 @@ Each API method definition includes:
|
||||
- This allows complex request/response structures (e.g., an object containing properties and a list of nested objects).
|
||||
- Template attributes retain the simpler four-type system. The extended types apply only to Inbound API method definitions and External System Gateway method definitions.
|
||||
|
||||
## Script Compilation & Hot-Reload
|
||||
|
||||
API method scripts are compiled at central startup — all method definitions are loaded from the configuration database and compiled into in-memory delegates.
|
||||
|
||||
### Update Workflow
|
||||
|
||||
- Updating a method via the CLI (`api-method update --id <N> --code '...'`) or Management API triggers immediate recompilation (`CompileAndRegister`). The updated script takes effect on the next API call — no node restart is required.
|
||||
- Creating a new method after startup: if the method is created but not yet compiled, the first invocation triggers lazy (on-demand) compilation.
|
||||
|
||||
### Direct SQL Warning
|
||||
|
||||
> **Do not edit API method scripts via direct SQL.** The in-memory compiled script will not be updated until the next node restart. Always use the CLI, Management API, or Central UI to modify API method scripts.
|
||||
|
||||
---
|
||||
|
||||
## API Call Logging
|
||||
|
||||
- **Only failures are logged.** Script execution errors (500 responses) are logged centrally.
|
||||
|
||||
@@ -209,6 +209,32 @@ When the Instance Actor is stopped (due to disable, delete, or redeployment), Ak
|
||||
|
||||
---
|
||||
|
||||
## Script Lifecycle
|
||||
|
||||
All script types can be updated without restarting the cluster, but the mechanism differs per type.
|
||||
|
||||
### Instance Scripts and Alarm On-Trigger Scripts
|
||||
|
||||
- Compiled at deployment time when the Deployment Manager receives a flattened configuration and creates the Instance Actor hierarchy.
|
||||
- **To update**: modify the script in the template, then redeploy the instance (`instance deploy --id <N>`).
|
||||
- Redeployment stops the existing Instance Actor and all its children, creates a new Instance Actor, and recompiles all scripts and alarms from the updated configuration.
|
||||
- There is no way to hot-reload a single instance script without redeploying the entire instance.
|
||||
|
||||
### Shared Scripts
|
||||
|
||||
- Compiled at the site when received from central via artifact deployment (`deploy artifacts`).
|
||||
- The `SharedScriptLibrary` replaces its in-memory compiled code dictionary under a lock, making updated code immediately available to all Script Actors.
|
||||
- **To update**: modify the shared script via the CLI or UI, then run `deploy artifacts` to push the change to sites.
|
||||
- No instance redeployment is required — running instances pick up the new shared script code on the next `Scripts.CallShared()` invocation.
|
||||
|
||||
### Inbound API Method Scripts
|
||||
|
||||
- See Component-InboundAPI.md for the compilation and hot-reload lifecycle of API method scripts.
|
||||
|
||||
> **Warning**: Editing scripts via direct SQL does not trigger recompilation. The in-memory compiled script will remain stale until the next node restart or redeployment. Always use the CLI, Management API, or Central UI to modify scripts.
|
||||
|
||||
---
|
||||
|
||||
## Script Runtime API
|
||||
|
||||
Available to all Script Execution Actors and Alarm Execution Actors:
|
||||
|
||||
@@ -1260,6 +1260,8 @@ scadalink --url <url> api-method update --id <int> [--name <string>] [--code <st
|
||||
| `--code` | no | Updated script source code (or `@filepath`) |
|
||||
| `--description` | no | Updated description |
|
||||
|
||||
Script changes take effect immediately — the updated code is recompiled in-memory on the active central node. No restart is required.
|
||||
|
||||
#### `api-method delete`
|
||||
|
||||
Delete an inbound API method.
|
||||
|
||||
Reference in New Issue
Block a user