-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinvariant-path-launcher
More file actions
executable file
·153 lines (125 loc) · 4.05 KB
/
Copy pathinvariant-path-launcher
File metadata and controls
executable file
·153 lines (125 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/usr/bin/env bash
# SPDX-License-Identifier: MPL-2.0
#
# Invariant Path Launcher (Quandle) - Standardized launcher following UX standards
# D-SIP-FV-MA Compliant: Dependable, Secure, Interoperable, Performant,
# Functional, Versatile, Metaiconic, Accessible
#
# Part of the nextgen-databases/quandledb repository.
# Wraps the core Invariant Path launcher for project-specific use.
set -euo pipefail
# ============================================================================
# CONFIGURATION
# ============================================================================
APP_NAME="InvariantPath-Quandle"
VERSION="1.0.0"
REPO_DIR="/var/mnt/eclipse/repos/nextgen-databases/quandledb"
CORE_LAUNCHER="/var/mnt/eclipse/repos/.desktop-tools/invariant-path-launcher.sh"
PID_FILE="/tmp/${APP_NAME,,}-server.pid"
LOG_FILE="/tmp/${APP_NAME,,}-server.log"
MODE="${1:---auto}"
# This wrapper only works on the maintainer's machine, where the core
# launcher and target repo exist. Everywhere else, fail with guidance
# instead of a confusing path error.
if [ ! -x "$CORE_LAUNCHER" ] || [ ! -d "$REPO_DIR" ]; then
echo "[$APP_NAME] core launcher or repo not found (maintainer machine only)." >&2
echo "[$APP_NAME] use: cargo run -p invariant-path-cli -- --help" >&2
exit 1
fi
# Colors for output
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# ============================================================================
# UTILITY FUNCTIONS
# ============================================================================
log() {
echo "[$APP_NAME] $1"
}
err() {
echo "[$APP_NAME] ERROR: $1" >&2
}
warn() {
echo "[$APP_NAME] WARNING: $1" >&2
}
is_running() {
[ -f "$PID_FILE" ] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null
}
# ============================================================================
# RUNTIME FUNCTIONS
# ============================================================================
start_app() {
if is_running; then
log "Application is already running (PID: $(cat "$PID_FILE"))"
return 0
fi
log "Starting Invariant Path scan for Quandle..."
# For Invariant Path, "starting" often means running a scan in background or
# keeping a service alive. Since it's a CLI tool, we'll perform a scan of
# the quandledb directory.
cd "$REPO_DIR"
# Run the core launcher's auto mode (which scans the repo) and background it
nohup "$CORE_LAUNCHER" --scan "$REPO_DIR" "generic" >"$LOG_FILE" 2>&1 &
echo $! > "$PID_FILE"
log "Scan started in background (PID: $(cat "$PID_FILE"))"
log "Log file: $LOG_FILE"
}
stop_app() {
if ! is_running; then
log "No running instance found"
return 0
fi
log "Stopping background processes..."
kill "$(cat "$PID_FILE")" 2>/dev/null || true
rm -f "$PID_FILE"
log "Stopped"
}
show_status() {
if is_running; then
log "Running (PID: $(cat "$PID_FILE"))"
else
log "Not running"
fi
log "Last scan results (if any):"
"$CORE_LAUNCHER" --status
}
# ============================================================================
# HELP AND VERSION
# ============================================================================
show_help() {
echo -e "${BLUE}${APP_NAME} ${VERSION}${NC}"
echo -e "${GREEN}Usage:${NC} $(basename "$0") [OPTION]"
echo ""
echo "Options:"
echo " --start Start a background scan of Quandle"
echo " --stop Stop any running background scan"
echo " --status Show status and last scan results"
echo " --scan Perform a foreground scan of Quandle"
echo " --auto Alias for --start (default)"
echo " --help Show this help message"
}
# ============================================================================
# MAIN SWITCH
# ============================================================================
case "$MODE" in
--start|--auto)
start_app
;;
--stop)
stop_app
;;
--status)
show_status
;;
--scan)
"$CORE_LAUNCHER" --scan "$REPO_DIR" "generic"
;;
--help|-h|--?)
show_help
;;
*)
# Fallback to auto
start_app
;;
esac