Use python instead of shell script, for datasync checks

seems to give more clarity, and we'll have more options this way
This commit is contained in:
Lance Edgar 2021-11-11 11:58:09 -06:00
parent 5b985fb803
commit b58c0da7a4
2 changed files with 59 additions and 32 deletions

View file

@ -1,20 +1,33 @@
#!/bin/sh
#!${envroot}/bin/python
TIMEOUT="$1"
if [ "$TIMEOUT" = "" ]; then
echo "Usage: check-datasync-queue TIMEOUT"
exit 3
fi
import os
import sys
import argparse
import subprocess
cd ${envroot}
bin/rattail -c app/quiet.conf --no-versioning datasync --timeout $TIMEOUT check 2>&1
rc=$?
if [ $rc -eq 1 ]; then
exit 2
elif [ $rc -ne 0 ]; then
echo "unknown issue"
exit 3
fi
def check_datasync_queue(timeout):
os.chdir(sys.prefix)
exit 0
retcode = subprocess.call([
'bin/rattail',
'-c', 'app/${config}.conf',
'--no-versioning',
'datasync',
'--timeout', timeout,
'check',
])
if retcode == 1:
sys.exit(2)
elif retcode:
print("unknown issue")
sys.exit(3)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('timeout')
args = parser.parse_args()
check_datasync_queue(args.timeout)

View file

@ -1,20 +1,34 @@
#!/bin/sh
#!${envroot}/bin/python
TIMEOUT="$1"
if [ "$TIMEOUT" = "" ]; then
echo "Usage: check-datasync-watchers TIMEOUT"
exit 3
fi
import os
import sys
import argparse
import subprocess
cd ${envroot}
bin/rattail -c app/datasync.conf -c app/quiet.conf --no-versioning datasync --timeout $TIMEOUT check-watchers 2>&1
rc=$?
if [ $rc -eq 1 ]; then
exit 2
elif [ $rc -ne 0 ]; then
echo "unknown issue"
exit 3
fi
def check_datasync_queue(timeout):
os.chdir(sys.prefix)
exit 0
retcode = subprocess.call([
'bin/rattail',
'-c', 'app/datasync.conf',
'-c', 'app/${config}.conf',
'--no-versioning',
'datasync',
'--timeout', timeout,
'check-watchers',
])
if retcode == 1:
sys.exit(2)
elif retcode:
print("unknown issue")
sys.exit(3)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('timeout')
args = parser.parse_args()
check_datasync_queue(args.timeout)