FreeBSD/jails/config/git/gitea-restart.sh

24 lines
701 B
Bash
Raw Permalink Normal View History

2021-05-06 15:19:21 -07:00
#!/usr/local/bin/bash
2022-04-19 13:46:35 -07:00
# Copyright (c) 2018-2022, diyIT.org
2021-05-06 15:19:21 -07:00
# All rights reserved.
#
# BSD 2-Clause License ("Simplified BSD License" or "FreeBSD License")
# https://diyit.org/license/
#
#
2022-04-19 13:38:56 -07:00
Q=`netstat -LAan | grep "*.3000" | cut -f3 -d" " | cut -f1 -d/`
2021-05-06 15:19:21 -07:00
# Q is null if gitea service is not running
2022-04-19 13:38:56 -07:00
# 1537 is max stuck recvQ qlen limit when logging start:
# sonewconn: pcb 0xfffff804b9f73d58: Listen queue overflow: 1537 already in queue awaiting acceptance (30 occurrences)
if [ ! "$Q" ] || [ $Q -ge 100 ]; then
2021-05-06 15:19:21 -07:00
echo "restarting gitea stuck at $Q"
tail /var/log/gitea/gitea.log
kill -9 `pgrep gitea` ; sleep 2 ; service gitea start
fi
# crontab - 5 * * * * /mnt/config/gitea-restart.sh