added new json-rpc-native mode

This commit is contained in:
Bernhard B 2026-03-21 19:49:26 +01:00
parent d45b906aa9
commit f142e8089c
4 changed files with 12 additions and 5 deletions

View File

@ -58,13 +58,14 @@ The `signal-cli-rest-api` supports three different modes of execution, which can
* **`normal` Mode: (Default)** The `signal-cli` executable is invoked for every REST API request. Being a Java application, each REST call requires a new startup of the JVM (Java Virtual Machine), increasing the latency and hence leading to the slowest mode of operation.
* **`native` Mode:** A precompiled binary `signal-cli-native` (using GraalVM) is used for every REST API request. This results in a much lower latency & memory usage on each call. On the `armv7` platform this mode is not available and falls back to `normal`. The native mode may also be less stable, due to the experimental state of GraalVM compiler.
* `json-rpc` Mode: A single, JVM-based `signal-cli` instance is spawned as daemon process. This mode is usually the fastest, but requires more memory as the JVM keeps running.
* `json-rpc-native` Mode: Uses the `signal-cli-native` binary and starts it in daemon mode (this mode basically combines the advantages of the `native` mode and the `json-rpc` mode).
| mode | speed | resident memory usage |
| ---------: | :------------------------------------------------------- | :-------------------- |
| `normal` | :heavy_check_mark: | normal |
| `native` | :heavy_check_mark: :heavy_check_mark: | normal |
| `json-rpc` | :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: | increased |
| `json-rpc-native` | :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: | normal |
**Example of running `signal-cli-rest` in `native` mode**

View File

@ -27,7 +27,7 @@ cap_prefix="-cap_"
caps="$cap_prefix$(seq -s ",$cap_prefix" 0 $(cat /proc/sys/kernel/cap_last_cap))"
# TODO: check mode
if [ "$MODE" = "json-rpc" ]
if [ "$MODE" = "json-rpc" ] || [ "$MODE" = "json-rpc-native" ]
then
/usr/bin/jsonrpc2-helper
if [ -n "$JAVA_OPTS" ] ; then

View File

@ -123,7 +123,7 @@ func main() {
mode := utils.GetEnv("MODE", "normal")
if mode == "normal" {
signalCliMode = client.Normal
} else if mode == "json-rpc" {
} else if mode == "json-rpc" || mode == "json-rpc-native" {
signalCliMode = client.JsonRpc
} else if mode == "native" {
signalCliMode = client.Native

View File

@ -13,7 +13,7 @@ import (
const supervisorctlConfigTemplate = `
[program:%s]
process_name=%s
command=signal-cli --output=json --config %s%s daemon %s%s%s%s --tcp 127.0.0.1:%d
command=%s --output=json --config %s%s daemon %s%s%s%s --tcp 127.0.0.1:%d
autostart=true
autorestart=true
startretries=10
@ -43,6 +43,12 @@ func main() {
jsonRpc2ClientConfig.AddEntry(utils.MULTI_ACCOUNT_NUMBER, utils.JsonRpc2ClientConfigEntry{TcpPort: tcpPort})
signalCliBinary := "signal-cli"
signalMode := utils.GetEnv("MODE", "json-rpc")
if signalMode == "json-rpc-native" {
signalCliBinary = "signal-cli-native"
}
signalCliIgnoreAttachments := ""
ignoreAttachments := utils.GetEnv("JSON_RPC_IGNORE_ATTACHMENTS", "")
if ignoreAttachments == "true" {
@ -91,7 +97,7 @@ func main() {
//write supervisorctl config
supervisorctlConfigFilename := "/etc/supervisor/conf.d/" + "signal-cli-json-rpc-1.conf"
supervisorctlConfig := fmt.Sprintf(supervisorctlConfigTemplate, supervisorctlProgramName, supervisorctlProgramName,
supervisorctlConfig := fmt.Sprintf(supervisorctlConfigTemplate, supervisorctlProgramName, supervisorctlProgramName, signalCliBinary,
signalCliConfigDir, trustNewIdentities, signalCliIgnoreAttachments, signalCliIgnoreStories,
signalCliIgnoreAvatars, signalCliIgnoreStickers, tcpPort,
supervisorctlProgramName, supervisorctlProgramName)