mirror of
https://github.com/bbernhard/signal-cli-rest-api.git
synced 2026-05-26 14:44:15 +00:00
added new json-rpc-native mode
This commit is contained in:
parent
d45b906aa9
commit
f142e8089c
@ -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.
|
* **`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.
|
* **`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` 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 |
|
| mode | speed | resident memory usage |
|
||||||
| ---------: | :------------------------------------------------------- | :-------------------- |
|
| ---------: | :------------------------------------------------------- | :-------------------- |
|
||||||
| `normal` | :heavy_check_mark: | normal |
|
| `normal` | :heavy_check_mark: | normal |
|
||||||
| `native` | :heavy_check_mark: :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` | :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**
|
**Example of running `signal-cli-rest` in `native` mode**
|
||||||
|
|||||||
@ -27,7 +27,7 @@ cap_prefix="-cap_"
|
|||||||
caps="$cap_prefix$(seq -s ",$cap_prefix" 0 $(cat /proc/sys/kernel/cap_last_cap))"
|
caps="$cap_prefix$(seq -s ",$cap_prefix" 0 $(cat /proc/sys/kernel/cap_last_cap))"
|
||||||
|
|
||||||
# TODO: check mode
|
# TODO: check mode
|
||||||
if [ "$MODE" = "json-rpc" ]
|
if [ "$MODE" = "json-rpc" ] || [ "$MODE" = "json-rpc-native" ]
|
||||||
then
|
then
|
||||||
/usr/bin/jsonrpc2-helper
|
/usr/bin/jsonrpc2-helper
|
||||||
if [ -n "$JAVA_OPTS" ] ; then
|
if [ -n "$JAVA_OPTS" ] ; then
|
||||||
|
|||||||
@ -123,7 +123,7 @@ func main() {
|
|||||||
mode := utils.GetEnv("MODE", "normal")
|
mode := utils.GetEnv("MODE", "normal")
|
||||||
if mode == "normal" {
|
if mode == "normal" {
|
||||||
signalCliMode = client.Normal
|
signalCliMode = client.Normal
|
||||||
} else if mode == "json-rpc" {
|
} else if mode == "json-rpc" || mode == "json-rpc-native" {
|
||||||
signalCliMode = client.JsonRpc
|
signalCliMode = client.JsonRpc
|
||||||
} else if mode == "native" {
|
} else if mode == "native" {
|
||||||
signalCliMode = client.Native
|
signalCliMode = client.Native
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import (
|
|||||||
const supervisorctlConfigTemplate = `
|
const supervisorctlConfigTemplate = `
|
||||||
[program:%s]
|
[program:%s]
|
||||||
process_name=%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
|
autostart=true
|
||||||
autorestart=true
|
autorestart=true
|
||||||
startretries=10
|
startretries=10
|
||||||
@ -43,6 +43,12 @@ func main() {
|
|||||||
|
|
||||||
jsonRpc2ClientConfig.AddEntry(utils.MULTI_ACCOUNT_NUMBER, utils.JsonRpc2ClientConfigEntry{TcpPort: tcpPort})
|
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 := ""
|
signalCliIgnoreAttachments := ""
|
||||||
ignoreAttachments := utils.GetEnv("JSON_RPC_IGNORE_ATTACHMENTS", "")
|
ignoreAttachments := utils.GetEnv("JSON_RPC_IGNORE_ATTACHMENTS", "")
|
||||||
if ignoreAttachments == "true" {
|
if ignoreAttachments == "true" {
|
||||||
@ -91,7 +97,7 @@ func main() {
|
|||||||
//write supervisorctl config
|
//write supervisorctl config
|
||||||
supervisorctlConfigFilename := "/etc/supervisor/conf.d/" + "signal-cli-json-rpc-1.conf"
|
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,
|
signalCliConfigDir, trustNewIdentities, signalCliIgnoreAttachments, signalCliIgnoreStories,
|
||||||
signalCliIgnoreAvatars, signalCliIgnoreStickers, tcpPort,
|
signalCliIgnoreAvatars, signalCliIgnoreStickers, tcpPort,
|
||||||
supervisorctlProgramName, supervisorctlProgramName)
|
supervisorctlProgramName, supervisorctlProgramName)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user