Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions signal-server-rs/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,21 @@ fi
UNIT_SRC="$(dirname "$0")/pkg/signal-server-rs.service"
if command -v systemctl >/dev/null 2>&1 && [ -f "$UNIT_SRC" ]; then
echo "[Deploy] Installing systemd unit..."

# systemd does not inherit this script's exports, so everything computed
# above has to be handed over in a file. Miss this and the server comes up on
# plain HTTP with no TURN.
RUNTIME_ENV=/etc/signal-server-rs.env
{
echo "PORT=${SIGNAL_PORT}"
echo "RELAY_PORT=${RELAY_PORT}"
echo "ICE_SERVERS=stun:${EXTERNAL_IP}:3478"
echo "TURN_SERVER=turn:${EXTERNAL_IP}:3478"
echo "RELAY_HOST=${DOMAIN:-${EXTERNAL_IP}}"
[ -n "$TLS_CERT" ] && echo "TLS_CERT_PATH=${TLS_CERT}"
[ -n "$TLS_KEY" ] && echo "TLS_KEY_PATH=${TLS_KEY}"
} | sudo tee "$RUNTIME_ENV" >/dev/null
sudo chmod 600 "$RUNTIME_ENV"
sudo cp "$UNIT_SRC" /etc/systemd/system/signal-server-rs.service
sudo systemctl daemon-reload
sudo systemctl enable signal-server-rs >/dev/null 2>&1 || true
Expand Down
21 changes: 12 additions & 9 deletions signal-server-rs/pkg/signal-server-rs.service
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,29 @@ Documentation=https://github.com/sashyo/keylessh/blob/main/docs/SIGNAL-SERVER.md
# coturn runs as a container and the server reads TURN settings at startup.
After=network-online.target docker.service
Wants=network-online.target
# Keep retrying indefinitely — a signal server that stays down is worse than
# one that keeps trying, and its absence shows up as a permissions error.
StartLimitIntervalSec=0

[Service]
Type=simple
User=azureuser
# Secrets live in the env file, so it is read by systemd rather than being
# baked into this unit. Root-owned and unreadable by the service user is fine —
# systemd reads it before dropping privileges.
# Runs as root, as the previous nohup deployment did: the TLS material it reads
# lives under /root/certs.
User=root

# Two files, and both are needed. The first holds the long-lived secrets. The
# second is written by deploy.sh and carries everything it computes at run time
# — TLS paths, ICE/TURN, relay host. Without it the server starts on plain HTTP
# with no TURN, and every wss:// client fails.
EnvironmentFile=/home/azureuser/keylessh/signal-server/.env
Environment=PORT=9090
EnvironmentFile=/etc/signal-server-rs.env
ExecStart=/home/azureuser/keylessh/signal-server-rs/target/release/signal-server-rs

# The whole point of this unit: a bare nohup process died on every reboot and
# nothing brought it back, which surfaced in the console as "contact your
# administrator to get server access".
Restart=always
RestartSec=5
# Do not give up after repeated quick failures — a signal server that stays
# down is worse than one that keeps retrying.
StartLimitIntervalSec=0

StandardOutput=journal
StandardError=journal
Expand All @@ -33,7 +37,6 @@ SyslogIdentifier=signal-server-rs
NoNewPrivileges=yes
PrivateTmp=yes
ProtectSystem=full
ProtectHome=read-only
ReadWritePaths=/tmp

[Install]
Expand Down
Loading