Skip to content

Commit

Permalink
add fooocus usage check
Browse files Browse the repository at this point in the history
  • Loading branch information
kalazus committed Feb 13, 2024
1 parent 0c372d2 commit adc5a34
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
8 changes: 7 additions & 1 deletion scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@ linkdir models

# Start application
cd $ORIGINALDIR
python entry_with_update.py --listen --port 3001 ${CMDARGS} > $DATADIR/fooocus.log 2>&1
FOOOCUS_LOGS=$DATADIR/fooocus.log
python entry_with_update.py --listen --port 3001 ${CMDARGS} > $FOOOCUS_LOGS 2>&1 &

# check usage
touch $FOOOCUS_LOGS
vast_usage 20 $FOOOCUS_LOGS

22 changes: 22 additions & 0 deletions scripts/vast_usage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
not_used_action() {
pip install vastai
vastai stop instance $CONTAINER_ID
}

check_usage() {
if [[ ! -f $2 ]]; then
echo "File not found"
exit 1
fi
local timeout=$(($1 * 60))
local timeleft=$timeout
while [[ $timeleft -gt 0 ]]; do
echo $timeleft
sleep $timeleft
local timeleft=$(($timeout - ($(date +%s) - $(date -r $2 +%s))))
done
echo "Self destruction"
not_used_action
}

check_usage $1 $2

0 comments on commit adc5a34

Please sign in to comment.