AdGuardHome icon indicating copy to clipboard operation
AdGuardHome copied to clipboard

add procd reload to openwrt systems

Open senposage opened this issue 1 year ago • 3 comments

Prerequisites

  • [X] I have checked the Wiki and Discussions and found no answer

  • [X] I have searched other issues and found no duplicates

  • [X] I want to request a feature or enhancement and not ask a question

The problem

currently the behavior of the init.d service is to die and not respawn when something unexpected happens such as a omm crash or other issue. openwrt lacks systemd so services can't restart them selves by default adding the proper procd to the init.d/adguardhome service addresses that

Proposed solution

add the following line to the init.d service so the service automatically attempts to restart after a crash or oom termination. after the following line: procd_set_param stderr 1 add the following line: procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}

Alternatives considered and additional information

ideally the respawn_threshhold should be equal or less then the minimum TTL to avoid interruptions in connectivity but this is a nice to have not a requirement

senposage avatar Aug 03 '24 16:08 senposage

edited for clarity

senposage avatar Aug 04 '24 17:08 senposage

I installed this on my wrt router about 1-2 weeks ago, and had it crash on me 2-3 times, I thought it was related to the log duration as someone else pointed out, but it wasn't.

Can this be easily added on my end or does the project have to support it, if so, adding my +1

EDIT: I just created a script to run rc.unslung check then start it back up if its dead. Feel free to use it. I added this script to /opt/etc/init.d/check.sh then made it executable, and added a cronjob in the ddwrt interface.

Cron */1 * * * * sh /opt/etc/init.d/check.sh AdGuardHome >> /opt/tmp/AdGuardHomeCheck.log 2>&1

Script

#!/bin/sh

SERVICE_NAME="$1"

if [ -z "$SERVICE_NAME" ]; then
    echo "Usage: $0 <service_name>"
    exit 1
fi

STATUS=$(/opt/etc/init.d/rc.unslung check "$SERVICE_NAME")

echo "$STATUS" | grep -q "dead"
if [ $? -eq 0 ]; then
    echo "$SERVICE_NAME is dead. Attempting to start..."
    /opt/etc/init.d/rc.unslung start "$SERVICE_NAME"
else
    echo "$SERVICE_NAME is already running."
fi

Rsslone avatar Feb 25 '25 08:02 Rsslone

@ainar-g has this change been reviewed / merged in yet ? just reinstall the latest openwrt stable. 0.107.57

senposage avatar May 08 '25 02:05 senposage