WWBN / AVideo

Create Your Own Broadcast Network With AVideo Platform Open-Source. OAVP OVP
https://avideo.tube/AVideo_OpenSource
Other
1.91k stars 972 forks source link

Why does this ssd fill? Is there no script to dump temp not happening? #7875

Open JoshWho opened 1 year ago

JoshWho commented 1 year ago

Seems like If I do not reboot nightly this fills up and causes 500 errors in all php

e40d2c04-78d3-4f40-ab7d-da9a72155d30

JoshWho commented 1 year ago

@DanielnetoDotCom I question this because you setup the SSD not really sure how u have it configured with the Cache plugin

DanielnetoDotCom commented 1 year ago

the cache is probably a symbolic link,

what folder/file is filling it up?

DanielnetoDotCom commented 1 year ago

FYI I have the following in my servers with small drives, it helps free some space

check those command lines and you can add them in the crontab if you want

https://github.com/WWBN/AVideo-Encoder/blob/master/install/deleteSystemdPrivate.php https://github.com/WWBN/AVideo-Encoder/blob/master/install/deleteAllQueueWithError.php

my crontab

20 * * * * php /var/www/html/AVideo-Encoder1/install/deleteAllQueueWithError.php
# reboot if server usage is over 90%
30 * * * * sh -c "if [ $(df / --output='pcent' | grep -o "[0-9]*") -gt 90 ]; then /sbin/shutdown -r now; fi"
# delete old tmp files
0 1 * * * php /root/deleteEncoderOldFiles.php

file deleteEncoderOldFiles.php

<?php
//0 1 * * * php /root/deleteEncoderOldFIles.php
error_reporting(E_ALL);
function deleteDirectory($dirPath) {
    if (!is_dir($dirPath)) {
        return;
    }

    $files = array_diff(scandir($dirPath), array('.', '..'));

    foreach ($files as $file) {
        $filePath = $dirPath . '/' . $file;
        if (is_dir($filePath)) {
            deleteDirectory($filePath);
        } else {
            unlink($filePath);
        }
    }

    rmdir($dirPath);
}
function deleteOldFilesAndDirs($dirPath, $olderThanInSeconds = 86400, $originalOlderThanInSeconds = 604800) {
    if (!is_dir($dirPath)) {
        return;
    }

    $now = time();
    $iterator = new RecursiveIteratorIterator(
        new RecursiveDirectoryIterator($dirPath, FilesystemIterator::SKIP_DOTS),
        RecursiveIteratorIterator::CHILD_FIRST
    );
    foreach ($iterator as $file) {
        $filename = $file->getFilename();
        $fileAgeInSeconds = $now - $file->getMTime();

        if ((strpos($filename, 'TmpFile') !== false || strpos($filename, 'thumbs_') !== false) &&
            $fileAgeInSeconds >= $olderThanInSeconds) {
                if ($file->isDir()) {
                    //deleteDirectory($file->getPathname());
                    exec("rm -R ".$file->getPathname());
                } else {
                    unlink($file->getPathname());
                }
        } elseif (strpos($filename, 'original_') !== false && $fileAgeInSeconds >= $originalOlderThanInSeconds) {
            if ($file->isDir()) {
                echo "Delete dir".PHP_EOL;
                //deleteDirectory($file->getPathname());
                exec("rm -R ".$file->getPathname());
            } else {
                echo "Delete file".PHP_EOL;
                unlink($file->getPathname());
            }
        }
    }
}
$encoderPaths = array(
    '/var/www/html/AVideo-Encoder/',
    '/var/www/html/AVideo-Encoder1/',
    '/var/www/html/AVideo-Encoder2/',
    '/var/www/html/AVideo-Encoder3/',
    '/var/www/html/AVideo-Encoder4/',
);

foreach ($encoderPaths as $key => $encoderPath) {
    echo "{$encoderPath}".PHP_EOL;
    deleteOldFilesAndDirs($encoderPath);

}
JoshWho commented 1 year ago

Do you see what my server is doing right now? @DanielnetoDotCom

JoshWho commented 1 year ago

I just rebooted it i couldn't let it stay offline

DanielnetoDotCom commented 1 year ago

Seems fine to me image

JoshWho commented 1 year ago

Because I rebooted it It was down for 40 minutes with a 500 error and the ssd was full again

b9479c28-c417-4ab7-a0dc-680f61c270cf

DanielnetoDotCom commented 1 year ago

what folder/file is filling it up?

?????

JoshWho commented 1 year ago

That I can never see it won't let me do anything when it is like that I have to reboot then the ssd isn't full after reboot, I am just guessing it is a temp folder since it clears after reboot.

DanielnetoDotCom commented 1 year ago

With command line you should be able to see what is filling it up

Also you do not need to wait it crash you can check now and save a screenshot and then check again in 1 hour to see what changes

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.