Passed
Push — develop ( 8130d1...5cdb4e )
by Nikolay
04:33
created

BeanstalkConf   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
c 1
b 0
f 0
dl 0
loc 15
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A reStart() 0 10 2
1
<?php
2
/*
3
 * Copyright (C) MIKO LLC - All Rights Reserved
4
 * Unauthorized copying of this file, via any medium is strictly prohibited
5
 * Proprietary and confidential
6
 * Written by Nikolay Beketov, 11 2020
7
 *
8
 */
9
10
namespace MikoPBX\Core\System\Configs;
11
12
13
use MikoPBX\Core\System\MikoPBXConfig;
14
use MikoPBX\Core\System\System;
15
use MikoPBX\Core\System\Util;
16
use Phalcon\Di;
17
use Phalcon\Di\Injectable;
18
19
class BeanstalkConf extends Injectable
20
{
21
    /**
22
     * Restarts Beanstalk server
23
     */
24
    public function reStart(): void
25
    {
26
        $beanstalkdPath = Util::which('beanstalkd');
27
        $conf = '-l 127.0.0.1 -p 4229 -z 524280';
28
        if (Util::isSystemctl()) {
29
            $systemCtrlPath = Util::which('systemctl');
30
            Util::mwExec("{$systemCtrlPath} restart beanstalkd.service");
31
        } else {
32
            Util::killByName('beanstalkd');
33
            Util::mwExec("{$beanstalkdPath} {$conf}");
34
        }
35
    }
36
}