Skip to content

Commit a208196

Browse files
committed
add webserver for replit 24/7
1 parent 8cd3bef commit a208196

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Diff for: .replit

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,9 @@ modules = ["php-8.2"]
33
run = "php main.php"
44

55
[nix]
6-
channel = "stable-24_05"
6+
channel = "stable-24_05"
7+
8+
[[ports]]
9+
localPort = 8000
10+
externalPort = 80
11+
exposeLocalhost = true

Diff for: main.php

+12
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@
2222
$GLOBALS['token'] = $TOKEN;
2323
$db = Database::get();
2424

25+
$command = "php -S 127.0.0.1:8000 main.php";
26+
27+
if (isset($_SERVER["REQUEST_URI"])) {
28+
die("Hello");
29+
}
30+
31+
if (pcntl_fork() == 0) {
32+
exec($command);
33+
} else {
34+
echo "Server started in background.\n";
35+
}
36+
2537
$discord = new Discord([
2638
'token' => $TOKEN,
2739
'intents' => Intents::getDefaultIntents(),

0 commit comments

Comments
 (0)