Skip to content

Commit 6dc034a

Browse files
committed
Fix hot-reload SIGHUP trigger and accept row numbers in TUI prompts
- Send SIGHUP after config rewrite to reliably trigger engine hot-reload (inotify can miss events through Docker bind mounts) - Allow secondary instance config updates even when primary is stopped - TUI label prompts now accept row # in addition to label name (#33)
1 parent 82a97e3 commit 6dc034a

1 file changed

Lines changed: 25 additions & 8 deletions

File tree

mtproxymax.sh

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2704,11 +2704,11 @@ restart_proxy_container() {
27042704
# Hot-reload: rewrite config.toml and let the engine pick it up (no restart, no dropped connections)
27052705
# Use this for secret/limit changes. Falls back to restart if container is not running.
27062706
reload_proxy_config() {
2707-
if ! is_proxy_running; then
2708-
return 0
2709-
fi
27102707
generate_telemt_config || { log_error "Config generation failed"; return 1; }
27112708

2709+
# Signal primary container to reload config (inotify may miss bind-mount changes)
2710+
is_proxy_running && docker kill -s SIGHUP "$CONTAINER_NAME" 2>/dev/null || true
2711+
27122712
# Also reload secondary instances if any
27132713
if [ -f "$INSTANCES_FILE" ]; then
27142714
load_instances 2>/dev/null
@@ -2720,6 +2720,7 @@ reload_proxy_config() {
27202720
PROXY_METRICS_PORT="${INSTANCE_METRICS_PORTS[$i]}"
27212721
generate_telemt_config
27222722
mv "${CONFIG_DIR}/config.toml" "$inst_config" 2>/dev/null
2723+
docker kill -s SIGHUP "mtproxymax-${INSTANCE_PORTS[$i]}" 2>/dev/null || true
27232724
done
27242725
PROXY_PORT="$_orig_port"
27252726
PROXY_METRICS_PORT="$_orig_mport"
@@ -5909,32 +5910,45 @@ show_secrets_menu() {
59095910
press_any_key
59105911
;;
59115912
2)
5912-
echo -en " ${BOLD}Label to remove:${NC} "
5913+
echo -en " ${BOLD}Label or # to remove:${NC} "
59135914
local label
59145915
read -r label
5916+
if [[ "$label" =~ ^[0-9]+$ ]] && [ "$label" -ge 1 ] && [ "$label" -le "${#SECRETS_LABELS[@]}" ]; then
5917+
label="${SECRETS_LABELS[$((label - 1))]}"
5918+
fi
59155919
[ -n "$label" ] && { secret_remove "$label" || true; }
59165920
press_any_key
59175921
;;
59185922
3)
5919-
echo -en " ${BOLD}Label to rotate:${NC} "
5923+
echo -en " ${BOLD}Label or # to rotate:${NC} "
59205924
local label
59215925
read -r label
5926+
if [[ "$label" =~ ^[0-9]+$ ]] && [ "$label" -ge 1 ] && [ "$label" -le "${#SECRETS_LABELS[@]}" ]; then
5927+
label="${SECRETS_LABELS[$((label - 1))]}"
5928+
fi
59225929
[ -n "$label" ] && { secret_rotate "$label" || true; }
59235930
press_any_key
59245931
;;
59255932
4)
5926-
echo -en " ${BOLD}Label to toggle:${NC} "
5933+
echo -en " ${BOLD}Label or # to toggle:${NC} "
59275934
local label
59285935
read -r label
5936+
if [[ "$label" =~ ^[0-9]+$ ]] && [ "$label" -ge 1 ] && [ "$label" -le "${#SECRETS_LABELS[@]}" ]; then
5937+
label="${SECRETS_LABELS[$((label - 1))]}"
5938+
fi
59295939
[ -n "$label" ] && { secret_toggle "$label" || true; }
59305940
press_any_key
59315941
;;
59325942
5)
59335943
secret_show_limits
59345944
echo ""
5935-
echo -en " ${BOLD}Label to set limits:${NC} "
5945+
echo -en " ${BOLD}Label or # to set limits:${NC} "
59365946
local label
59375947
read -r label
5948+
# If user entered a number, map to the label at that index
5949+
if [[ "$label" =~ ^[0-9]+$ ]] && [ "$label" -ge 1 ] && [ "$label" -le "${#SECRETS_LABELS[@]}" ]; then
5950+
label="${SECRETS_LABELS[$((label - 1))]}"
5951+
fi
59385952
if [ -n "$label" ]; then
59395953
echo -en " ${BOLD}Max TCP connections (0=unlimited):${NC} "
59405954
local mc; read -r mc
@@ -5971,9 +5985,12 @@ show_secrets_menu() {
59715985
press_any_key
59725986
;;
59735987
8)
5974-
echo -en " ${BOLD}Label:${NC} "
5988+
echo -en " ${BOLD}Label or #:${NC} "
59755989
local note_label
59765990
read -r note_label
5991+
if [[ "$note_label" =~ ^[0-9]+$ ]] && [ "$note_label" -ge 1 ] && [ "$note_label" -le "${#SECRETS_LABELS[@]}" ]; then
5992+
note_label="${SECRETS_LABELS[$((note_label - 1))]}"
5993+
fi
59775994
if [ -n "$note_label" ]; then
59785995
secret_edit_note "$note_label" || true
59795996
fi

0 commit comments

Comments
 (0)