generated from coulomb/repo-seed
chore(deploy): add haskelseed Alpine startup scripts
Some checks failed
Test / test (push) Has been cancelled
Some checks failed
Test / test (push) Has been cancelled
OpenRC init script + RunDevServer env wrapper for the haskelseed build VM (Alpine 3.23, GHC 9.10.3, IHP 1.5). IHP DevServer binds to 127.0.0.1:8000 so socat forwards 0.0.0.0:8080 → 127.0.0.1:8000 for external access. Deploy steps are documented in the file headers. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
20
deploy/haskelseed/interhub-rundevserver
Normal file
20
deploy/haskelseed/interhub-rundevserver
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Wrapper called by /etc/init.d/interhub — sets required env vars and execs RunDevServer.
|
||||||
|
# Deploy to: /usr/local/bin/interhub-rundevserver (chmod +x)
|
||||||
|
#
|
||||||
|
# IHP_SESSION_SECRET below is a dev placeholder — replace for any non-local deployment.
|
||||||
|
|
||||||
|
GHC_BIN="/nix/store/ssq6yzl7ldy743g15wskzbgryd9zkk7g-ghc-9.10.3-with-packages/bin"
|
||||||
|
|
||||||
|
export PATH="${GHC_BIN}:/usr/local/bin:/usr/bin:/bin"
|
||||||
|
export IHP_LIB="/nix/store/zr688g6g7b41zrilmbggv1rca6xyghbi-ihp-env-var-backwards-compat"
|
||||||
|
export DATABASE_URL="postgresql://ihp:ihp@127.0.0.1/interhub"
|
||||||
|
export PGHOST="127.0.0.1"
|
||||||
|
export IHP_SESSION_SECRET="aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899"
|
||||||
|
export IHP_BASEURL="http://192.168.178.135:8000"
|
||||||
|
export PORT="8000"
|
||||||
|
export GHCRTS="-A256m -M20g"
|
||||||
|
export IHP_ENV="Development"
|
||||||
|
|
||||||
|
cd /root/inter-hub
|
||||||
|
exec "${GHC_BIN}/RunDevServer"
|
||||||
68
deploy/haskelseed/interhub.openrc
Normal file
68
deploy/haskelseed/interhub.openrc
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
#!/sbin/openrc-run
|
||||||
|
# OpenRC init script for inter-hub on haskelseed (Alpine 3.23, OpenRC 0.63).
|
||||||
|
# Deploy to: /etc/init.d/interhub (chmod +x)
|
||||||
|
# Enable: rc-update add postgresql default && rc-update add interhub default
|
||||||
|
#
|
||||||
|
# Also required in /etc/conf.d/postgresql:
|
||||||
|
# data_dir="/var/lib/postgresql17/data"
|
||||||
|
#
|
||||||
|
# App is exposed publicly on port 8080 (socat forward from IHP's 127.0.0.1:8000).
|
||||||
|
# Logs: /var/log/interhub/rundevserver.log and /var/log/interhub/socat.log
|
||||||
|
|
||||||
|
name="inter-hub"
|
||||||
|
description="IHF v0.2 reference implementation (RunDevServer + socat forward)"
|
||||||
|
|
||||||
|
IHUB_DIR="/root/inter-hub"
|
||||||
|
LOG_DIR="/var/log/interhub"
|
||||||
|
RUNDEV_LOG="${LOG_DIR}/rundevserver.log"
|
||||||
|
SOCAT_LOG="${LOG_DIR}/socat.log"
|
||||||
|
RUNDEV_PID="${LOG_DIR}/rundevserver.pid"
|
||||||
|
SOCAT_PID="${LOG_DIR}/socat.pid"
|
||||||
|
|
||||||
|
GHC_BIN="/nix/store/ssq6yzl7ldy743g15wskzbgryd9zkk7g-ghc-9.10.3-with-packages/bin"
|
||||||
|
|
||||||
|
depend() {
|
||||||
|
need postgresql
|
||||||
|
after nix-daemon
|
||||||
|
}
|
||||||
|
|
||||||
|
start() {
|
||||||
|
ebegin "Starting inter-hub"
|
||||||
|
|
||||||
|
mkdir -p "${LOG_DIR}"
|
||||||
|
|
||||||
|
# Ensure GHCi can read .ghci (rsync restores build:build ownership)
|
||||||
|
chown -R root:root "${IHUB_DIR}"
|
||||||
|
|
||||||
|
# Start RunDevServer via wrapper (wrapper sets all required env vars)
|
||||||
|
start-stop-daemon --start \
|
||||||
|
--background \
|
||||||
|
--make-pidfile --pidfile "${RUNDEV_PID}" \
|
||||||
|
--stdout "${RUNDEV_LOG}" --stderr "${RUNDEV_LOG}" \
|
||||||
|
--exec /usr/local/bin/interhub-rundevserver
|
||||||
|
|
||||||
|
# Wait up to 90 s for RunDevServer to bind port 8000
|
||||||
|
local waited=0
|
||||||
|
while [ $waited -lt 90 ]; do
|
||||||
|
netstat -tn 2>/dev/null | grep -q "127.0.0.1:8000" && break
|
||||||
|
sleep 3
|
||||||
|
waited=$((waited + 3))
|
||||||
|
done
|
||||||
|
|
||||||
|
# Expose the app on all interfaces at port 8080
|
||||||
|
start-stop-daemon --start \
|
||||||
|
--background \
|
||||||
|
--make-pidfile --pidfile "${SOCAT_PID}" \
|
||||||
|
--stdout "${SOCAT_LOG}" --stderr "${SOCAT_LOG}" \
|
||||||
|
--exec /usr/bin/socat -- \
|
||||||
|
TCP-LISTEN:8080,bind=0.0.0.0,reuseaddr,fork TCP:127.0.0.1:8000
|
||||||
|
|
||||||
|
eend $?
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
ebegin "Stopping inter-hub"
|
||||||
|
start-stop-daemon --stop --pidfile "${SOCAT_PID}" --quiet
|
||||||
|
start-stop-daemon --stop --pidfile "${RUNDEV_PID}" --quiet
|
||||||
|
eend $?
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user