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

IlyasDeckers / ody-core / 13568209044

27 Feb 2025 02:03PM UTC coverage: 28.467% (-0.7%) from 29.138%
13568209044

push

github

IlyasDeckers
run websockets as daemon

0 of 52 new or added lines in 4 files covered. (0.0%)

544 of 1911 relevant lines covered (28.47%)

8.56 hits per line

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

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

3
namespace Ody\Core\Console\Commands;
4

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

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

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

31
        return self::SUCCESS;
×
32
    }
33

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

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

NEW
71
        foreach (getWebsocketWorkerProcessIds() as $index => $workerId) {
×
NEW
72
            $index++;
×
NEW
73
            if (posix_kill($workerId, SIG_DFL)) {
×
NEW
74
                $rows[] = [
×
NEW
75
                    "Websocket process $index",
×
NEW
76
                    '<fg=#C3E88D;options=bold> ACTIVE </>',
×
NEW
77
                    $workerId
×
NEW
78
                ];
×
NEW
79
                continue;
×
80
            }
NEW
81
            $rows[] = [
×
NEW
82
                "Worker worker $index",
×
83
                '<fg=#FF5572;options=bold> DEACTIVE </>',
×
84
                $workerId
×
85
            ];
×
86
        }
87

88
        $output->writeln('');
×
89
        $table = new Table($output);
×
90
        $table
×
91
            ->setHeaderTitle('full information')
×
92
            ->setHeaders([
×
93
                '<fg=#FFCB8B;options=bold> Process Name </>',
×
94
                '<fg=#FFCB8B;options=bold> Process Status </>',
×
95
                '<fg=#FFCB8B;options=bold> Process PID </>'
×
96
            ])
×
97
            ->setRows($rows);
×
98
        $table->setVertical();
×
99
        $table->render();
×
100
        $output->writeln('');
×
101
    }
102

103
    protected function generalInformation(OutputInterface $output): void
×
104
    {
105
        $output->writeln('');
×
106
        $table = new Table($output);
×
107
        $table
×
108
            ->setHeaderTitle('general information')
×
109
            ->setHeaders([
×
110
                '<fg=#FFCB8B;options=bold> Process Name </>',
×
111
                '<fg=#FFCB8B;options=bold> Process Status </>',
×
112
                '<fg=#FFCB8B;options=bold> Process PID </>'
×
113
            ])
×
114
            ->setRows([
×
115
                [
×
NEW
116
                    'HTTP 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()
×
NEW
117
                ],
×
NEW
118
                [
×
NEW
119
                    'Websocket server', (!is_null(getWebsocketManagerProcessId()) && posix_kill(getWebsocketManagerProcessId(), SIG_DFL)) && (!is_null(getWebsocketMasterProcessId()) && posix_kill(getWebsocketMasterProcessId(), SIG_DFL)) ? '<fg=#C3E88D;options=bold> ACTIVE </>' : '<fg=#FF5572;options=bold> DEACTIVE </>', getWebsocketManagerProcessId()
×
120
                ],
×
121
                [
×
122
                    'watcher', !is_null(getWatcherProcessId()) && posix_kill(getWatcherProcessId(), SIG_DFL) ? '<fg=#C3E88D;options=bold> ACTIVE </>' : '<fg=#FF5572;options=bold> DEACTIVE </>', getWatcherProcessId()
×
123
                ],
×
124
                [
×
125
                    'factory', !is_null(getFactoryProcessId()) && posix_kill(getFactoryProcessId(), SIG_DFL) ? '<fg=#C3E88D;options=bold> ACTIVE </>' : '<fg=#FF5572;options=bold> DEACTIVE </>', getFactoryProcessId()
×
126
                ],
×
127
                [
×
128
                    'queue', (!is_null(getQueueProcessId()) && posix_kill(getQueueProcessId(), SIG_DFL)) ? '<fg=#C3E88D;options=bold> ACTIVE </>' : '<fg=#FF5572;options=bold> DEACTIVE </>', getQueueProcessId()
×
129
                ]
×
130
            ]);
×
131
        $table->setVertical();
×
132
        $table->render();
×
133
        $output->writeln('');
×
134
    }
135
}
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