Bearsampp 2026.5.5
Loading...
Searching...
No Matches
class.action.exec.php
Go to the documentation of this file.
1<?php
2/*
3 *
4 * * Copyright (c) 2022-2025 Bearsampp
5 * * License: GNU General Public License version 3 or later; see LICENSE.txt
6 * * Website: https://bearsampp.com
7 * * Github: https://github.com/Bearsampp
8 *
9 */
10
19{
23 const QUIT = 'quit';
24
28 const RESTART = 'restart';
29
39 public function __construct($args)
40 {
41 global $bearsamppCore;
42
43 Log::trace('ActionExec constructor called');
44
45 $execFile = $bearsamppCore->getExec();
46 Log::trace('Checking for exec file: ' . $execFile);
47
48 if (file_exists($execFile)) {
49 Log::trace('Exec file exists');
50
51 $action = file_get_contents($execFile);
52 Log::trace('Action read from exec file: "' . $action . '"');
53
54 if ($action == self::QUIT) {
55 Log::trace('Executing quit action');
57 } elseif ($action == self::RESTART) {
58 Log::trace('Executing restart action');
60 } else {
61 Log::trace('Unknown action: "' . $action . '"');
62 }
63
64 // Do NOT delete the exec file yet if it's a restart,
65 // as we need the next instance to know it's a restart.
66 // ActionStartup will handle the unlinking.
67 if ($action != self::RESTART) {
68 Log::trace('Deleting exec file');
69 $unlinkResult = @unlink($execFile);
70 Log::trace('Unlink result: ' . ($unlinkResult ? 'success' : 'failed'));
71 }
72 } else {
73 Log::trace('Exec file does not exist: ' . $execFile);
74 }
75 }
76}
global $bearsamppCore
static exitApp($restart=false)
static restartApp()
static trace($data, $file=null)