-
Notifications
You must be signed in to change notification settings - Fork 16
chore: replace graphql server #1875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2a31900
537f783
f73919a
9ddae2e
f83aa5c
9557998
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,89 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #!/bin/bash | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # /etc/rc.d/rc.unraid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Unraid Phoenix Application Service | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| APP_DIR="/usr/local/unraid" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| RELEASE_BIN="$APP_DIR/_build/prod/rel/unraid/bin/unraid" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CONFIG_DIR="/boot/config/unraid" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SOCKET_PATH="/var/run/unraid-core.sock" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| LOG_PATH="${UNRAID_LOG_PATH:-/var/log/unraid-core.log}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Load user env if exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [ -f "$CONFIG_DIR/env" ] && source "$CONFIG_DIR/env" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Ensure config and log directories exist | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p "$CONFIG_DIR" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mkdir -p "$(dirname "$LOG_PATH")" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| touch "$LOG_PATH" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Generate secret_key_base if not exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ ! -f "$CONFIG_DIR/secret_key_base" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| head -c 64 /dev/urandom | base64 | tr -d '\n' > "$CONFIG_DIR/secret_key_base" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| chmod 600 "$CONFIG_DIR/secret_key_base" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export SECRET_KEY_BASE=$(cat "$CONFIG_DIR/secret_key_base") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export RELEASE_COOKIE=$(cat "$CONFIG_DIR/secret_key_base" | head -c 20) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export UNRAID_CONFIG_DIR="$CONFIG_DIR" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export RUN_ERL_LOG="${RUN_ERL_LOG:-$LOG_PATH}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export RELEASE_LOG_DIR="${RELEASE_LOG_DIR:-$(dirname "$LOG_PATH")}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export RELEASE_NODE="${UNRAID_RELEASE_NODE:-unraid}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export RELEASE_DISTRIBUTION="${UNRAID_RELEASE_DISTRIBUTION:-sname}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export RELEASE_MODE="${UNRAID_RELEASE_MODE:-interactive}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Import user's runtime.exs if exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [ -f "$CONFIG_DIR/runtime.exs" ] && export RELEASE_CONFIG_DIR="$CONFIG_DIR" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # Socket/port configuration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ -n "${UNRAID_PORT:-}" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export PHX_PORT="$UNRAID_PORT" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export PHX_SOCKET="${UNRAID_SOCKET:-$SOCKET_PATH}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| start() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo -n "Starting Unraid... " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [ -S "$SOCKET_PATH" ] && rm -f "$SOCKET_PATH" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "$RELEASE_BIN" daemon | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "done" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stop() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo -n "Stopping Unraid... " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "$RELEASE_BIN" stop 2>/dev/null || true | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [ -S "$SOCKET_PATH" ] && rm -f "$SOCKET_PATH" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "done" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| restart() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sleep 2 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| start | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| status() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "$RELEASE_BIN" pid >/dev/null 2>&1 && echo "Running" || echo "Stopped" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rollback() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if [ -d "/usr/local/unraid.prev" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Rolling back to previous version..." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rm -rf /usr/local/unraid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mv /usr/local/unraid.prev /usr/local/unraid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| start | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "Rollback complete" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| echo "No previous version available" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| exit 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+68
to
+80
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rollback operation is not atomic and risks data loss. If the 🔧 Suggested safer rollback rollback() {
if [ -d "/usr/local/unraid.prev" ]; then
echo "Rolling back to previous version..."
stop
- rm -rf /usr/local/unraid
- mv /usr/local/unraid.prev /usr/local/unraid
+ # Atomic swap: rename current to .old, then prev to current
+ rm -rf /usr/local/unraid.old 2>/dev/null
+ mv /usr/local/unraid /usr/local/unraid.old && \
+ mv /usr/local/unraid.prev /usr/local/unraid && \
+ rm -rf /usr/local/unraid.old
start
echo "Rollback complete"
else📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case "${1:-}" in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| start) start ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| stop) stop ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| restart) restart ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| status) status ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| rollback) rollback ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| *) echo "Usage: $0 {start|stop|restart|status|rollback}" ;; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| esac | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #!/bin/sh | ||
| # Stop Unraid Core on shutdown/reboot | ||
|
|
||
| if [ -x /etc/rc.d/rc.unraid ]; then | ||
| echo "Stopping Unraid Core..." | ||
| /etc/rc.d/rc.unraid stop | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: unraid/api
Length of output: 722
🏁 Script executed:
Repository: unraid/api
Length of output: 1437
🏁 Script executed:
Repository: unraid/api
Length of output: 1699
Use a more specific pattern for core package matching.
The glob pattern
unraid-*on line 339 could match unrelated packages likeunraid-apiif they're installed in/var/log/packages/. Since the core package follows a version-based naming convention (e.g.,unraid-0.1.0-2026.01.14.1), use:Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents