2015-07-26 01:58:11 +02:00
|
|
|
#!/usr/bin/env bash
|
2015-08-12 10:20:44 +02:00
|
|
|
# Shell script to start PyLink under CPUlimit, throttling it if it starts abusing the CPU.
|
2015-07-26 01:58:11 +02:00
|
|
|
|
|
|
|
# Set this to whatever you want. cpulimit --help
|
2015-08-12 10:20:44 +02:00
|
|
|
LIMIT=35
|
2015-07-26 01:58:11 +02:00
|
|
|
|
|
|
|
# Change to the PyLink root directory.
|
|
|
|
WRAPPER_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
|
|
cd "$WRAPPER_DIR"
|
|
|
|
|
|
|
|
if [[ ! -z "$(which cpulimit)" ]]; then
|
|
|
|
# -z makes cpulimit exit when PyLink dies.
|
2015-08-12 10:20:44 +02:00
|
|
|
cpulimit -l $LIMIT -z ./main.py
|
|
|
|
echo "PyLink has been started (daemonized) under cpulimit, and will automatically be throttled if it goes over the CPU limit of ${LIMIT}%."
|
2015-07-26 01:58:11 +02:00
|
|
|
echo "To kill the process manually, run ./kill.sh"
|
|
|
|
else
|
|
|
|
echo 'cpulimit not found in $PATH! Aborting.'
|
|
|
|
fi
|