File tree Expand file tree Collapse file tree 1 file changed +26
-4
lines changed Expand file tree Collapse file tree 1 file changed +26
-4
lines changed Original file line number Diff line number Diff line change 3
3
set -u
4
4
set -o pipefail
5
5
6
- if searchd --status 1> /dev/null; then
7
- exit 0
8
- else
6
+ # the service is considered to be ready for connections if
7
+ # searchd --status is running
8
+ # last sync of index files exists and is not older than 5 minutes
9
+
10
+ # check if searchd is running
11
+ searchd --status 1> /dev/null || exit 1
12
+
13
+ # check if index files are up-to-date
14
+ LAST_SYNC=" /tmp/last_sync_finished.txt"
15
+ MAX_AGE=300 # max age in seconds should be the same interval as the cron settings
16
+
17
+ # check if index sync status file exists
18
+ if [[ ! -f " ${LAST_SYNC} " ]]; then
19
+ echo " index sync status file does not exist ${LAST_SYNC} "
20
+ exit 1
21
+ fi
22
+
23
+ # Calculate the time MAX_AGE seconds ago in seconds
24
+ five_mins_ago=$(( $(date +% s) - MAX_AGE ))
25
+ # Get the file's last modification time in seconds
26
+ file_mtime=$( stat -c %Y " ${LAST_SYNC} " )
27
+
28
+ # check if index sync status file is up-to-date
29
+ if [[ $file_mtime -lt $five_mins_ago ]]; then
30
+ echo " index sync status file is outdated: ${LAST_SYNC} "
9
31
exit 1
10
- fi
32
+ fi
You can’t perform that action at this time.
0 commit comments