-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
106 changed files
with
4,030 additions
and
5,071 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,44 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
#!/bin/sh | ||
|
||
use Spacetab\Logger\Logger; | ||
use StaticServer\Application as Server; | ||
use StaticServer\Console\DumpConfigCommand; | ||
use StaticServer\Console\ReloadServerCommand; | ||
use StaticServer\Console\RunServerCommand; | ||
use StaticServer\Console\SignalHandler; | ||
use StaticServer\Console\StopServerCommand; | ||
use Symfony\Component\Console\Application; | ||
set -e | ||
|
||
$locations = [ | ||
__DIR__ . '/../../../autoload.php', | ||
__DIR__ . '/../vendor/autoload.php', | ||
__DIR__ . '/vendor/autoload.php' | ||
]; | ||
# export PATH="$PATH:$(pwd)/bin" | ||
|
||
foreach ($locations as $file) { | ||
if (file_exists($file)) { | ||
require_once $file; | ||
break; | ||
} | ||
} | ||
SERVER_CONFIG_PATH="$(template handler --dump config)" | ||
|
||
$logger = Logger::default('Fatal'); | ||
CLEAR='\033[0m' | ||
RED='\033[0;31m' | ||
|
||
pcntl_async_signals(true); | ||
usage() { | ||
echo "Static webserver. Version: $SERVER_VERSION" | ||
if [ -n "$1" ]; then | ||
echo "${RED}👉 $1${CLEAR}\n"; | ||
fi | ||
echo "Usage: $0 [ run | reload | stop | dump ]" | ||
echo "" | ||
echo "Example: $0 run or STAGE=local $0 run" | ||
exit 1 | ||
} | ||
|
||
$sig = new SignalHandler(); | ||
pcntl_signal(SIGTERM, [$sig, 'handle']); | ||
pcntl_signal(SIGINT, [$sig, 'handle']); | ||
pcntl_signal(SIGQUIT, [$sig, 'handle']); | ||
pcntl_signal(SIGUSR1, [$sig, 'handle']); | ||
while [ "$#" -gt 0 ]; do | ||
case $1 in | ||
run) run=1; ;; | ||
reload) reload=1; ;; | ||
stop) stop=1; ;; | ||
dump) dump=1; ;; | ||
*) usage "Unknown parameter passed: $1" ;; | ||
esac | ||
shift | ||
done | ||
|
||
try { | ||
$app = new Application('Static server', getenv('SERVER_VERSION')); | ||
$app->add(new RunServerCommand()); | ||
$app->add(new StopServerCommand()); | ||
$app->add(new DumpConfigCommand()); | ||
$app->add(new ReloadServerCommand()); | ||
$app->run(); | ||
} catch (Throwable $e) { | ||
$logger->critical($e->getMessage(), ['trace' => $e->getTraceAsString()]); | ||
exit(1); | ||
} | ||
if [ "$run" = "1" ]; then | ||
template generate && nginx -c "$SERVER_CONFIG_PATH" | ||
elif [ "$reload" = "1" ]; then | ||
template generate && nginx -c "$SERVER_CONFIG_PATH" -s reload | ||
elif [ "$stop" = "1" ]; then | ||
template generate && nginx -c "$SERVER_CONFIG_PATH" -s stop | ||
elif [ "$dump" = "1" ]; then | ||
template dump | ||
else | ||
usage | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
|
||
use Spacetab\Logger\Logger; | ||
use Spacetab\Server\Console\DumpCommand; | ||
use Spacetab\Server\Console\GenerateCommand; | ||
use Spacetab\Server\Console\HandlerCommand; | ||
use Symfony\Component\Console\Application; | ||
|
||
$locations = [ | ||
__DIR__ . '/../../../autoload.php', | ||
__DIR__ . '/../vendor/autoload.php', | ||
__DIR__ . '/vendor/autoload.php' | ||
]; | ||
|
||
foreach ($locations as $file) { | ||
if (file_exists($file)) { | ||
require_once $file; | ||
break; | ||
} | ||
} | ||
|
||
$logger = Logger::default('Fatal'); | ||
|
||
try { | ||
$app = new Application('Static server', getenv('SERVER_VERSION')); | ||
$app->add(new DumpCommand()); | ||
$app->add(new GenerateCommand()); | ||
$app->add(new HandlerCommand()); | ||
$app->run(); | ||
} catch (Throwable $e) { | ||
$logger->critical($e->getMessage(), ['trace' => $e->getTraceAsString()]); | ||
exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM php:8.0-cli-alpine | ||
|
||
RUN wget https://github.com/box-project/box/releases/download/3.11.1/box.phar \ | ||
&& mv box.phar /usr/local/bin/box \ | ||
&& chmod +x /usr/local/bin/box | ||
|
||
RUN set -xe \ | ||
apk update --no-cache \ | ||
&& apk add --no-cache icu icu-dev ca-certificates \ | ||
&& docker-php-ext-install intl | ||
|
||
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer | ||
|
||
# It validates requirements first, then print command list. | ||
RUN box | ||
|
||
ENTRYPOINT ["box"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"output": "bin/server.phar", | ||
"main": "bin/server" | ||
"output": "bin/template.phar", | ||
"main": "bin/template" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.