This commit is contained in:
Your Name
2024-02-15 23:42:27 -06:00
parent 8c60f0956b
commit c93bda5316
3 changed files with 57 additions and 7 deletions

View File

@@ -1,4 +1,11 @@
bash /data/openpilot/shell/configure_ssh.sh cd bash /data/openpilot/shell/
bash /data/openpilot/shell/set_logo.sh
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" screen -dmS "watcher" "bash /data/openpilot/shell/watcher_run_loop.sh"

View File

@@ -192,5 +192,38 @@ const server = http.createServer((req, res) => {
}); });
server.listen(port, hostname, () => { 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();

View File

@@ -3,9 +3,19 @@ cd /data/openpilot/shell
while true while true
do 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 done