Bearsampp
2026.7.11
Toggle main menu visibility
Loading...
Searching...
No Matches
class.action.stopAllServices.php
Go to the documentation of this file.
1
<?php
2
/*
3
* Copyright (c) 2021-2024 Bearsampp
4
* License: GNU General Public License version 3 or later; see LICENSE.txt
5
* Author: Bear
6
* Website: https://bearsampp.com
7
* Github: https://github.com/Bearsampp
8
*/
9
14
class
ActionStopAllServices
15
{
19
private
$splash
;
20
24
private
$processed
=
false
;
25
29
const
GAUGE_PER_SERVICE
= 1;
30
37
public
function
__construct
($args)
38
{
39
global
$bearsamppCore
,
$bearsamppLang
,
$bearsamppBins
, $bearsamppWinbinder;
40
41
// Count enabled services for progress bar
42
$enabledServicesCount = count(
$bearsamppBins
->getServices());
43
44
// Start splash screen
45
$this->splash =
new
Splash
();
46
$this->splash->init(
47
$bearsamppLang
->getValue(
Lang::MENU_STOP_SERVICES
),
48
self::GAUGE_PER_SERVICE * $enabledServicesCount + 1,
49
$bearsamppLang
->getValue(
Lang::LOADING_STOP_SERVICES
)
50
);
51
52
// Set handler for the splash screen window with 1000ms timeout
53
$bearsamppWinbinder->setHandler($this->splash->getWbWindow(), $this,
'processWindow'
, 1000);
54
$bearsamppWinbinder->mainLoop();
55
$bearsamppWinbinder->reset();
56
}
57
69
public
function
processWindow
($window, $id, $ctrl, $param1, $param2)
70
{
71
global
$bearsamppBins
,
$bearsamppLang
, $bearsamppWinbinder;
72
73
// Only process once
74
if
($this->processed) {
75
return
;
76
}
77
$this->processed =
true
;
78
79
// Use parallel shutdown for optimized performance (40-60% faster than sequential)
80
// Falls back to sequential if parallel times out
81
ServiceHelper::stopAllServicesParallel
(
82
$bearsamppBins
,
83
function
($current, $total, $serviceName) use (
$bearsamppLang
) {
84
$this->splash->incrProgressBar();
85
$this->splash->setTextLoading(sprintf(
$bearsamppLang
->getValue(
Lang::LOADING_STOP_SERVICE
), $serviceName));
86
}
87
);
88
89
// Final update
90
$this->splash->incrProgressBar();
91
$this->splash->setTextLoading(
$bearsamppLang
->getValue(
Lang::LOADING_COMPLETE
));
92
93
// Close the splash screen and exit cleanly
94
$bearsamppWinbinder->destroyWindow($window);
95
$bearsamppWinbinder->reset();
96
exit
(0);
97
}
98
}
99
$bearsamppBins
global $bearsamppBins
Definition
ajax.apache.php:16
$bearsamppLang
global $bearsamppLang
Definition
ajax.apache.php:16
exit
exit
Definition
ajax.apply.moduleconfig.php:63
$bearsamppCore
global $bearsamppCore
Definition
ajax.latestversion.php:24
ActionStopAllServices
Definition
class.action.stopAllServices.php:15
ActionStopAllServices\__construct
__construct($args)
Definition
class.action.stopAllServices.php:37
ActionStopAllServices\$splash
$splash
Definition
class.action.stopAllServices.php:19
ActionStopAllServices\$processed
$processed
Definition
class.action.stopAllServices.php:24
ActionStopAllServices\processWindow
processWindow($window, $id, $ctrl, $param1, $param2)
Definition
class.action.stopAllServices.php:69
ActionStopAllServices\GAUGE_PER_SERVICE
const GAUGE_PER_SERVICE
Definition
class.action.stopAllServices.php:29
Lang\LOADING_STOP_SERVICES
const LOADING_STOP_SERVICES
Definition
class.lang.php:264
Lang\LOADING_COMPLETE
const LOADING_COMPLETE
Definition
class.lang.php:267
Lang\MENU_STOP_SERVICES
const MENU_STOP_SERVICES
Definition
class.lang.php:120
Lang\LOADING_STOP_SERVICE
const LOADING_STOP_SERVICE
Definition
class.lang.php:265
ServiceHelper\stopAllServicesParallel
static stopAllServicesParallel($bearsamppBins, ?callable $progressCallback=null, $shutdownTimeout=15)
Definition
class.servicehelper.php:230
Splash
Definition
class.splash.php:17
sandbox
core
classes
actions
class.action.stopAllServices.php
Generated by
1.17.0