summaryrefslogtreecommitdiffhomepage
path: root/bin
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-05-28 09:42:55 +0900
committerAdam Malczewski <[email protected]>2026-05-28 09:42:55 +0900
commit1e70f2d12274da833035912206b1ac0b1ee57ef1 (patch)
treec87cb29a36d833228f2e1e16f94fcc920d8ca17e /bin
parent6662622e1c89fa1124b7342f136ab5f8d3c97972 (diff)
downloaddispatch-1e70f2d12274da833035912206b1ac0b1ee57ef1.tar.gz
dispatch-1e70f2d12274da833035912206b1ac0b1ee57ef1.zip
feat: add agent status indicator in chat input, db tabs tests, and service management script
Diffstat (limited to 'bin')
-rwxr-xr-xbin/service85
1 files changed, 85 insertions, 0 deletions
diff --git a/bin/service b/bin/service
new file mode 100755
index 0000000..eaa63eb
--- /dev/null
+++ b/bin/service
@@ -0,0 +1,85 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
+PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
+
+cmd="${1:-help}"
+shift 2>/dev/null || true
+
+usage() {
+ cat <<EOF
+Usage: bin/service <command>
+
+Commands:
+ install Install the dispatch packages (systemd user units +
+ application files in /opt/dispatch).
+ start Start dispatch-api and dispatch-frontend.
+ If already running, restart instead.
+ Prints the frontend URL when ready.
+ stop Stop dispatch-api and dispatch-frontend.
+ status Show status of both services.
+ logs Tail journal output for both services.
+
+After install, configure /etc/dispatch/dispatch-api.conf before starting.
+EOF
+}
+
+install() {
+ echo "==> Building fresh package..."
+ "$PROJECT_DIR/bin/build-pkg"
+
+ echo ""
+ echo "==> Installing..."
+ "$PROJECT_DIR/bin/install-pkg"
+
+ systemctl --user daemon-reload
+ echo ""
+ echo "==> Installed. Edit /etc/dispatch/dispatch-api.conf, then run:"
+ echo " bin/service start"
+}
+
+have_units() {
+ systemctl --user cat dispatch-api.service &>/dev/null
+}
+
+start() {
+ if ! have_units; then
+ echo "dispatch services not installed. Run: bin/service install"
+ return 1
+ fi
+ local api_active frontend_active
+ api_active=$(systemctl --user is-active dispatch-api 2>/dev/null || echo "inactive")
+ frontend_active=$(systemctl --user is-active dispatch-frontend 2>/dev/null || echo "inactive")
+
+ if [ "$api_active" = "active" ] || [ "$frontend_active" = "active" ]; then
+ echo "==> Services already running (api=$api_active frontend=$frontend_active) — restarting"
+ systemctl --user restart dispatch-api dispatch-frontend
+ else
+ systemctl --user start dispatch-api dispatch-frontend
+ fi
+ echo "dispatch-api + dispatch-frontend $( [ "$api_active" = "active" ] || [ "$frontend_active" = "active" ] && echo restarted || echo started )"
+ echo " → http://localhost:18391"
+}
+
+status() {
+ if ! have_units; then
+ echo "dispatch services not installed."
+ return 1
+ fi
+ systemctl --user status dispatch-api dispatch-frontend --no-pager 2>/dev/null || true
+}
+
+logs() {
+ journalctl --user -u dispatch-api -u dispatch-frontend -f "$@"
+}
+
+case "$cmd" in
+ install) install ;;
+ start) start ;;
+ stop) stop ;;
+ status) status ;;
+ logs) logs "$@" ;;
+ help|--help|-h) usage ;;
+ *) echo "Unknown command: $cmd"; echo; usage; exit 1 ;;
+esac