• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IlyasDeckers / ody-core / 13532154862

25 Feb 2025 10:24PM UTC coverage: 30.374% (+1.7%) from 28.706%
13532154862

push

github

web-flow
Update php.yml

544 of 1791 relevant lines covered (30.37%)

9.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Console/Commands/Server/StatusCommand.php
1
<?php
2

3
namespace Ody\Core\Console\Commands\Server;
4

5
use Swoole\Process;
6
use Symfony\Component\Console\Attribute\AsCommand;
7
use Symfony\Component\Console\Command\Command;
8
use Symfony\Component\Console\Helper\Table;
9
use Symfony\Component\Console\Input\InputInterface;
10
use Symfony\Component\Console\Input\InputOption;
11
use Symfony\Component\Console\Output\OutputInterface;
12

13
#[AsCommand(
14
    name: 'server:status',
×
15
    description: 'status http server'
×
16
)]
×
17
class StatusCommand extends Command
18
{
19
    protected function configure(): void
×
20
    {
21
        $this->addOption('full', 'f', InputOption::VALUE_NONE, 'Display full information about the status of processes');
×
22
    }
23

24
    protected function execute(InputInterface $input, OutputInterface $output): int
×
25
    {
26
        if ($input->getOption('full')) {
×
27
            $this->fullInformation($output);
×
28
        } else {
29
            $this->generalInformation($output);
×
30
        }
31

32
        return self::SUCCESS;
×
33
    }
34

35
    protected function fullInformation(OutputInterface $output): void
×
36
    {
37
        $rows = [
×
38
            [
×
39
                'manager', !is_null(getManagerProcessId()) && posix_kill(getManagerProcessId(), SIG_DFL) ? '<fg=#C3E88D;options=bold> ACTIVE </>' : '<fg=#FF5572;options=bold> DEACTIVE </>', getManagerProcessId()
×
40
            ],
×
41
            [
×
42
                'master', !is_null(getMasterProcessId()) && posix_kill(getMasterProcessId(), SIG_DFL) ? '<fg=#C3E88D;options=bold> ACTIVE </>' : '<fg=#FF5572;options=bold> DEACTIVE </>', getMasterProcessId()
×
43
            ],
×
44
            [
×
45
                'watcher', !is_null(getWatcherProcessId()) && posix_kill(getWatcherProcessId(), SIG_DFL) ? '<fg=#C3E88D;options=bold> ACTIVE </>' : '<fg=#FF5572;options=bold> DEACTIVE </>', getWatcherProcessId()
×
46
            ],
×
47
            [
×
48
                'factory', !is_null(getFactoryProcessId()) && posix_kill(getFactoryProcessId(), SIG_DFL) ? '<fg=#C3E88D;options=bold> ACTIVE </>' : '<fg=#FF5572;options=bold> DEACTIVE </>', getWatcherProcessId()
×
49
            ],
×
50
            [
×
51
                'queue', (!is_null(getQueueProcessId()) && posix_kill(getQueueProcessId(), SIG_DFL)) ? '<fg=#C3E88D;options=bold> ACTIVE </>' : '<fg=#FF5572;options=bold> DEACTIVE </>', getQueueProcessId()
×
52
            ]
×
53
        ];
×
54

55
        foreach (getWorkerProcessIds() as $index => $workerId) {
×
56
            $index++;
×
57
            if (posix_kill($workerId, SIG_DFL)) {
×
58
                $rows[] = [
×
59
                    "process $index",
×
60
                    '<fg=#C3E88D;options=bold> ACTIVE </>',
×
61
                    $workerId
×
62
                ];
×
63
                continue;
×
64
            }
65
            $rows[] = [
×
66
                "worker $index",
×
67
                '<fg=#FF5572;options=bold> DEACTIVE </>',
×
68
                $workerId
×
69
            ];
×
70
        }
71

72
        $output->writeln('');
×
73
        $table = new Table($output);
×
74
        $table
×
75
            ->setHeaderTitle('full information')
×
76
            ->setHeaders([
×
77
                '<fg=#FFCB8B;options=bold> Process Name </>',
×
78
                '<fg=#FFCB8B;options=bold> Process Status </>',
×
79
                '<fg=#FFCB8B;options=bold> Process PID </>'
×
80
            ])
×
81
            ->setRows($rows);
×
82
        $table->setVertical();
×
83
        $table->render();
×
84
        $output->writeln('');
×
85
    }
86

87
    protected function generalInformation(OutputInterface $output): void
×
88
    {
89
        $output->writeln('');
×
90
        $table = new Table($output);
×
91
        $table
×
92
            ->setHeaderTitle('general information')
×
93
            ->setHeaders([
×
94
                '<fg=#FFCB8B;options=bold> Process Name </>',
×
95
                '<fg=#FFCB8B;options=bold> Process Status </>',
×
96
                '<fg=#FFCB8B;options=bold> Process PID </>'
×
97
            ])
×
98
            ->setRows([
×
99
                [
×
100
                    'server', (!is_null(getManagerProcessId()) && posix_kill(getManagerProcessId(), SIG_DFL)) && (!is_null(getMasterProcessId()) && posix_kill(getMasterProcessId(), SIG_DFL)) ? '<fg=#C3E88D;options=bold> ACTIVE </>' : '<fg=#FF5572;options=bold> DEACTIVE </>', getManagerProcessId()
×
101
                ],
×
102
                [
×
103
                    'watcher', !is_null(getWatcherProcessId()) && posix_kill(getWatcherProcessId(), SIG_DFL) ? '<fg=#C3E88D;options=bold> ACTIVE </>' : '<fg=#FF5572;options=bold> DEACTIVE </>', getWatcherProcessId()
×
104
                ],
×
105
                [
×
106
                    'factory', !is_null(getFactoryProcessId()) && posix_kill(getFactoryProcessId(), SIG_DFL) ? '<fg=#C3E88D;options=bold> ACTIVE </>' : '<fg=#FF5572;options=bold> DEACTIVE </>', getFactoryProcessId()
×
107
                ],
×
108
                [
×
109
                    'queue', (!is_null(getQueueProcessId()) && posix_kill(getQueueProcessId(), SIG_DFL)) ? '<fg=#C3E88D;options=bold> ACTIVE </>' : '<fg=#FF5572;options=bold> DEACTIVE </>', getQueueProcessId()
×
110
                ]
×
111
            ]);
×
112
        $table->setVertical();
×
113
        $table->render();
×
114
        $output->writeln('');
×
115
    }
116
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc