ework-aio 0.1.11 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/install.sh +83 -10
- package/package.json +1 -1
package/bin/install.sh
CHANGED
|
@@ -39,6 +39,7 @@ NO_START=0
|
|
|
39
39
|
ASSUME_YES=0
|
|
40
40
|
NO_RESTART=0
|
|
41
41
|
CFG_ARGS=()
|
|
42
|
+
MODE_ARGS=()
|
|
42
43
|
|
|
43
44
|
usage() {
|
|
44
45
|
cat <<'EOF'
|
|
@@ -80,10 +81,19 @@ while [[ $# -gt 0 ]]; do
|
|
|
80
81
|
MODE="config"
|
|
81
82
|
shift
|
|
82
83
|
# Consume remaining args as config subcommand + its positionals.
|
|
84
|
+
# Global flags (--data-dir, --user, --system, etc.) are still
|
|
85
|
+
# respected here so `config set K V --data-dir X` works as expected.
|
|
83
86
|
while [[ $# -gt 0 ]]; do
|
|
84
87
|
case "$1" in
|
|
85
88
|
--no-restart) NO_RESTART=1; shift ;;
|
|
86
89
|
-h|--help) CFG_ARGS=("help"); shift ;;
|
|
90
|
+
--user) SCOPENAME="--user"; shift ;;
|
|
91
|
+
--system) SCOPENAME="--system"; shift ;;
|
|
92
|
+
--data-dir) DATA_DIR="$2"; shift 2 ;;
|
|
93
|
+
--port) WORK_PORT="$2"; shift 2 ;;
|
|
94
|
+
--daemon-port) DAEMON_PORT="$2"; shift 2 ;;
|
|
95
|
+
--bot-name) BOT_NAME="$2"; shift 2 ;;
|
|
96
|
+
--yes|-y) ASSUME_YES=1; shift ;;
|
|
87
97
|
*) CFG_ARGS+=("$1"); shift ;;
|
|
88
98
|
esac
|
|
89
99
|
done
|
|
@@ -98,7 +108,8 @@ while [[ $# -gt 0 ]]; do
|
|
|
98
108
|
--no-restart) NO_RESTART=1; shift ;;
|
|
99
109
|
--yes|-y) ASSUME_YES=1; shift ;;
|
|
100
110
|
-h|--help) usage; exit 0 ;;
|
|
101
|
-
|
|
111
|
+
--*) die "Unknown option: $1 (try --help)" ;;
|
|
112
|
+
*) MODE_ARGS+=("$1"); shift ;;
|
|
102
113
|
esac
|
|
103
114
|
done
|
|
104
115
|
|
|
@@ -144,12 +155,13 @@ ensure_user_session || true # warn but don't hard-fail — let later steps rep
|
|
|
144
155
|
need_cmd() {
|
|
145
156
|
command -v "$1" >/dev/null 2>&1 || die "Missing required command: $1. $2"
|
|
146
157
|
}
|
|
147
|
-
# Commands every mode needs (status/logs/env/config/uninstall all use systemctl).
|
|
148
|
-
need_cmd systemctl "This installer requires systemd."
|
|
149
158
|
need_cmd awk "Should be present on any Linux."
|
|
150
159
|
|
|
151
|
-
#
|
|
160
|
+
# install needs systemctl (to write unit files + reload). Other modes
|
|
161
|
+
# (status/logs/env/config/uninstall) can fall back to PID-file mode via
|
|
162
|
+
# the 'ework-aio' dispatcher if systemd is unreachable on this host.
|
|
152
163
|
if [[ "$MODE" == "install" ]]; then
|
|
164
|
+
need_cmd systemctl "Install requires systemd. For hosts without systemd, run 'npm install -g ework-aio' and use 'ework-aio start' directly (PID-file mode)."
|
|
153
165
|
need_cmd bun "Install from https://bun.sh"
|
|
154
166
|
need_cmd npm "Install Node.js or Bun (ships npm)"
|
|
155
167
|
need_cmd opencode "Install from https://opencode.ai"
|
|
@@ -158,6 +170,23 @@ if [[ "$MODE" == "install" ]]; then
|
|
|
158
170
|
need_cmd jq "Install jq (for opencode.json merge)."
|
|
159
171
|
fi
|
|
160
172
|
|
|
173
|
+
# EWORK_AIO_BIN: always resolvable (used by status/logs/config/uninstall
|
|
174
|
+
# to delegate to PID-file mode operations when systemd is unreachable).
|
|
175
|
+
EWORK_AIO_BIN="$(command -v ework-aio 2>/dev/null || true)"
|
|
176
|
+
[[ -n "$EWORK_AIO_BIN" ]] || EWORK_AIO_BIN="$(npm root -g 2>/dev/null)/ework-aio/bin/ework-aio"
|
|
177
|
+
|
|
178
|
+
# systemd_reachable: 0 if `systemctl $SCOPENAME` can talk to systemd, 1 if not.
|
|
179
|
+
# Used by status/logs/config/uninstall to decide whether to use systemd
|
|
180
|
+
# (preferred) or fall back to PID-file mode via the ework-aio dispatcher.
|
|
181
|
+
# Hosts where this returns 1: containers without systemd PID 1, polkit
|
|
182
|
+
# redirects under sudo that drop the bus, hosts where the user isn't
|
|
183
|
+
# permissioned for the system bus.
|
|
184
|
+
systemd_reachable() {
|
|
185
|
+
command -v systemctl >/dev/null 2>&1 || return 1
|
|
186
|
+
systemctl "$SCOPENAME" is-system-running >/dev/null 2>&1 \
|
|
187
|
+
|| systemctl "$SCOPENAME" list-units --no-pager >/dev/null 2>&1
|
|
188
|
+
}
|
|
189
|
+
|
|
161
190
|
# Verify the 3 npm packages are reachable. If not, try to install them now.
|
|
162
191
|
ensure_pkg() {
|
|
163
192
|
local pkg="$1"
|
|
@@ -469,6 +498,19 @@ service_for_key() {
|
|
|
469
498
|
restart_service() {
|
|
470
499
|
local svc="$1"
|
|
471
500
|
local rc=0
|
|
501
|
+
if ! systemd_reachable; then
|
|
502
|
+
log "systemd not reachable — using PID-file mode restart"
|
|
503
|
+
if [[ "$svc" == "both" ]]; then
|
|
504
|
+
"$EWORK_AIO_BIN" restart both && ok "Restarted ework-web + ework-daemon (PID-file mode)" || rc=$?
|
|
505
|
+
else
|
|
506
|
+
"$EWORK_AIO_BIN" restart "$svc" && ok "Restarted ework-$svc (PID-file mode)" || rc=$?
|
|
507
|
+
fi
|
|
508
|
+
if [[ $rc -ne 0 ]]; then
|
|
509
|
+
warn "PID-file restart of '$svc' failed (exit $rc)."
|
|
510
|
+
warn "The .env changes are saved; run 'ework-aio restart $svc' manually."
|
|
511
|
+
fi
|
|
512
|
+
return $rc
|
|
513
|
+
fi
|
|
472
514
|
case "$svc" in
|
|
473
515
|
web) ctl restart ework-web.service && ok "Restarted ework-web" || rc=$? ;;
|
|
474
516
|
daemon) ctl restart ework-daemon.service && ok "Restarted ework-daemon" || rc=$? ;;
|
|
@@ -622,7 +664,22 @@ config)
|
|
|
622
664
|
;;
|
|
623
665
|
|
|
624
666
|
status)
|
|
625
|
-
hr; log "ework-aio status
|
|
667
|
+
hr; log "ework-aio status"; hr
|
|
668
|
+
if ! systemd_reachable; then
|
|
669
|
+
log "(systemd unreachable — showing PID-file mode status)"
|
|
670
|
+
"$EWORK_AIO_BIN" ps 2>/dev/null || warn "ework-aio ps failed"
|
|
671
|
+
hr
|
|
672
|
+
log "Port listeners:"
|
|
673
|
+
p=""
|
|
674
|
+
for p in $(grep -hE '^(WORK_PORT|DAEMON_PORT)=' "$WEB_ENV" "$DAEMON_ENV" 2>/dev/null | cut -d= -f2 | sort -u); do
|
|
675
|
+
if curl -sf -o /dev/null --max-time 1 "http://127.0.0.1:$p/login" 2>/dev/null; then
|
|
676
|
+
printf ' :%s ✓ listening\n' "$p"
|
|
677
|
+
else
|
|
678
|
+
printf ' :%s ✗ not responding\n' "$p"
|
|
679
|
+
fi
|
|
680
|
+
done
|
|
681
|
+
exit 0
|
|
682
|
+
fi
|
|
626
683
|
ctl is-active ework-web.service || true
|
|
627
684
|
ctl is-active ework-daemon.service || true
|
|
628
685
|
ctl status --no-pager --lines=0 ework-web.service 2>/dev/null || true
|
|
@@ -632,18 +689,34 @@ status)
|
|
|
632
689
|
;;
|
|
633
690
|
|
|
634
691
|
logs)
|
|
635
|
-
svc="${
|
|
692
|
+
svc="${MODE_ARGS[0]:-ework-web.service}"
|
|
636
693
|
[[ "$svc" == "daemon" || "$svc" == "ework-daemon" ]] && svc="ework-daemon.service"
|
|
637
694
|
[[ "$svc" == "web" || "$svc" == "ework-web" ]] && svc="ework-web.service"
|
|
695
|
+
if ! systemd_reachable; then
|
|
696
|
+
svc_short="${svc%.service}"
|
|
697
|
+
svc_short="${svc_short#ework-}"
|
|
698
|
+
log_file="$DATA_DIR/run/${svc_short}.log"
|
|
699
|
+
if [[ ! -f "$log_file" ]]; then
|
|
700
|
+
die "systemd unreachable and no PID-file log at $log_file. Start services with: ework-aio start $svc_short"
|
|
701
|
+
fi
|
|
702
|
+
log "(systemd unreachable — tailing PID-file log $log_file)"
|
|
703
|
+
exec tail -n 200 -f "$log_file"
|
|
704
|
+
fi
|
|
638
705
|
exec journalctl "$SCOPENAME" -u "$svc" -f
|
|
639
706
|
;;
|
|
640
707
|
|
|
641
708
|
uninstall)
|
|
642
709
|
hr; log "Uninstalling ework-aio services (keeping data)"; hr
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
710
|
+
"$EWORK_AIO_BIN" stop both 2>/dev/null || true
|
|
711
|
+
if systemd_reachable; then
|
|
712
|
+
ctl stop ework-web.service ework-daemon.service 2>/dev/null || true
|
|
713
|
+
ctl disable ework-web.service ework-daemon.service 2>/dev/null || true
|
|
714
|
+
rm -f "$UNIT_DIR/ework-web.service" "$UNIT_DIR/ework-daemon.service"
|
|
715
|
+
ctl daemon-reload 2>/dev/null || true
|
|
716
|
+
else
|
|
717
|
+
log "(systemd unreachable — skipped unit cleanup; PID-file mode services stopped above)"
|
|
718
|
+
rm -f "$UNIT_DIR/ework-web.service" "$UNIT_DIR/ework-daemon.service" 2>/dev/null || true
|
|
719
|
+
fi
|
|
647
720
|
ok "Services removed. Data preserved at $DATA_DIR"
|
|
648
721
|
warn "To fully remove: rm -rf $DATA_DIR && npm uninstall -g ework-aio ework-web ework-daemon opencode-ework"
|
|
649
722
|
exit 0
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ework-aio",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "All-in-one installer for ework (issue tracker) + ework-daemon (AI bridge) + opencode-ework (plugin). One command: npm i -g ework-aio && ework-aio install.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|