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

BeanstalkConf::reStart()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 10
rs 10
cc 2
nc 2
nop 0
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
}