wip
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
bash /data/openpilot/shell/configure_ssh.sh
|
||||
bash /data/openpilot/shell/set_logo.sh
|
||||
cd bash /data/openpilot/shell/
|
||||
|
||||
bash ./configure_ssh.sh
|
||||
bash ./set_logo.sh
|
||||
|
||||
cd /data/openpilot/logs
|
||||
|
||||
rm -f watcher.log.gz
|
||||
ls watcher.log && gzip watcher.log
|
||||
|
||||
screen -dmS "watcher" "bash /data/openpilot/shell/watcher_run_loop.sh"
|
||||
@@ -192,5 +192,38 @@ const server = http.createServer((req, res) => {
|
||||
});
|
||||
|
||||
server.listen(port, hostname, () => {
|
||||
console.log(`Server running at http://${hostname}:${port}/`);
|
||||
});
|
||||
console.log(`Web Server running at http://${hostname}:${port}/`);
|
||||
});
|
||||
|
||||
//// Exit when low disk space /////
|
||||
|
||||
const { exec } = require('child_process');
|
||||
|
||||
// Function to check disk space
|
||||
function checkDiskSpace() {
|
||||
exec('df -BG /data | tail -n 1 | awk \'{print $4}\'', (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.error(`exec error: ${error}`);
|
||||
return;
|
||||
}
|
||||
if (stderr) {
|
||||
console.error(`stderr: ${stderr}`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Extract the number of GBs available
|
||||
const freeSpaceGB = parseInt(stdout.trim().replace('G', ''));
|
||||
|
||||
// Check if free space is less than 10GB
|
||||
if (freeSpaceGB < 9) {
|
||||
console.log('Less than 9GB of free space on /data. Exiting.');
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Check disk space every 1 minute
|
||||
setInterval(checkDiskSpace, 60000);
|
||||
|
||||
// Perform an initial check
|
||||
checkDiskSpace();
|
||||
|
||||
@@ -3,9 +3,19 @@ cd /data/openpilot/shell
|
||||
while true
|
||||
do
|
||||
|
||||
nodejs watcher.js
|
||||
nodejs watcher.js
|
||||
|
||||
|
||||
echo crashed, waiting 30 seconds
|
||||
sleep 30
|
||||
# Get free space on /data in GB
|
||||
free_space=$(df -BG /data | tail -n 1 | awk '{print $4}' | sed 's/G//')
|
||||
|
||||
# Check if free space is less than 10GB
|
||||
if [ "$free_space" -lt 10 ]; then
|
||||
echo "Less than 10GB of free space on /data. Exiting."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo crashed, waiting 30 seconds
|
||||
sleep 30
|
||||
|
||||
done
|
||||
Reference in New Issue
Block a user