src/Core.php
public function handleSignal($signum)
    {
        $consts     = get_defined_constants(true);
        $signame    = '???';
        foreach ($consts['pcntl'] as $name => $value) {
            if (!strncmp($name, 'SIG', 3) &&
                strncmp($name, 'SIG_', 4) &&
                $signum == $value) {
                $signame = $name;
                break;
            }
        }

        $logger = \Plop\Plop::getInstance();
        $logger->info(
            $this->gettext(
                'Received signal #%(signum)d (%(signame)s)'
            ),
            array(
                'signum'    => $signum,
                'signame'   => $signame,
            )
        );

        // Print some statistics.
        if (function_exists('memory_get_peak_usage')) {
            $logger->debug($this->gettext('Memory usage:'));

            $limit  = trim(ini_get('memory_limit'));
            $limit  = \Erebot\Utils::parseHumanSize($limit."B");
            $stats  = array(
                (string) $this->gettext("Allocated:") =>
                    \Erebot\Utils::humanSize(memory_get_peak_usage(true)),
                (string) $this->gettext("Used:") =>
                    \Erebot\Utils::humanSize(memory_get_peak_usage(false)),
                (string) $this->gettext("Limit:") =>
                    \Erebot\Utils::humanSize($limit),
            );

            foreach ($stats as $key => $value) {
                $logger->debug(
                    '%(key)-16s%(value)10s',
                    array(
                        'key'   => $key,
                        'value' => $value,
                    )
                );
            }
        }

        $this->stop();
    }
public function handleSignal($signum)
    {
        $consts     = get_defined_constants(true);
        $signame    = '???';
        foreach ($consts['pcntl'] as $name => $value) {
            if (!strncmp($name, 'SIG', 3) &&
                strncmp($name, 'SIG_', 4) &&
                $signum == $value) {
                $signame = $name;
                break;
            }
        }

        $logger = \Plop\Plop::getInstance();
        $logger->info(
            $this->gettext(
                'Received signal #%(signum)d (%(signame)s)'
            ),
            array(
                'signum'    => $signum,
                'signame'   => $signame,
            )
        );

        // Print some statistics.
        if (function_exists('memory_get_peak_usage')) {
            $logger->debug($this->gettext('Memory usage:'));

            $limit  = trim(ini_get('memory_limit'));
            $limit  = \Erebot\Utils::parseHumanSize($limit."B");
            $stats  = array(
                (string) $this->gettext("Allocated:") =>
                    \Erebot\Utils::humanSize(memory_get_peak_usage(true)),
                (string) $this->gettext("Used:") =>
                    \Erebot\Utils::humanSize(memory_get_peak_usage(false)),
                (string) $this->gettext("Limit:") =>
                    \Erebot\Utils::humanSize($limit),
            );

            foreach ($stats as $key => $value) {
                $logger->debug(
                    '%(key)-16s%(value)10s',
                    array(
                        'key'   => $key,
                        'value' => $value,
                    )
                );
            }
        }

        $this->stop();
    }
public function handleSignal ( $ signum ) { $ consts = get_defined_constants ( true ) ; $ signame = '???' ; foreach ( $ consts [ 'pcntl' ] as $ name => $ value ) { if ( ! strncmp ( $ name , 'SIG' , 3 ) && strncmp ( $ name , 'SIG_' , 4 ) && $ signum == $ value ) { $ signame = $ name ; break ; } } $ logger = \ Plop \ Plop :: getInstance ( ) ; $ logger -> info ( $ this -> gettext ( 'Received signal #%(signum)d (%(signame)s)' ) , array ( 'signum' => $ signum , 'signame' => $ signame , ) ) ; // Print some statistics. if ( function_exists ( 'memory_get_peak_usage' ) ) { $ logger -> debug ( $ this -> gettext ( 'Memory usage:' ) ) ; $ limit = trim ( ini_get ( 'memory_limit' ) ) ; $ limit = \ Erebot \ Utils :: parseHumanSize ( $ limit . "B" ) ; $ stats = array ( ( string ) $ this -> gettext ( "Allocated:" ) => \ Erebot \ Utils :: humanSize ( memory_get_peak_usage ( true ) ) , ( string ) $ this -> gettext ( "Used:" ) => \ Erebot \ Utils :: humanSize ( memory_get_peak_usage ( false ) ) , ( string ) $ this -> gettext ( "Limit:" ) => \ Erebot \ Utils :: humanSize ( $ limit ) , ) ; foreach ( $ stats as $ key => $ value ) { $ logger -> debug ( '%(key)-16s%(value)10s' , array ( 'key' => $ key , 'value' => $ value , ) ) ; } } $ this -> stop ( ) ; }
Handles request for a graceful shutdown of the bot.
Such requests are received as signals.

\param int $signum
The number of the signal.
Handles request for a graceful shutdown of the bot . Such requests are received as signals .