Removed no longer unused files, added WS_TZ for timezone in preparation for beta release at the end of the month.
This commit is contained in:
@@ -295,6 +295,7 @@ None that we are aware of.
|
||||
- (string) `WS_CRON_IMPORT_AT` cron expression timer.
|
||||
- (string) `WS_CRON_EXPORT_AT` cron expression timer.
|
||||
- (string) `WS_CRON_PUSH_AT` cron expression timer.
|
||||
- (string) `WS_TZ` Set timezone for example, `UTC`
|
||||
|
||||
# Container specific environment variables
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ return (function () {
|
||||
$config = [
|
||||
'name' => 'WatchState',
|
||||
'version' => 'v0.0.0',
|
||||
'tz' => null,
|
||||
'tz' => env('WS_TS', 'UTC'),
|
||||
'path' => fixPath(env('WS_DATA_PATH', fn() => env('IN_DOCKER') ? '/config' : realpath(__DIR__ . '/../var'))),
|
||||
];
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
tz: Asia/Kuwait
|
||||
logger:
|
||||
stderr:
|
||||
level: INFO
|
||||
file:
|
||||
enabled: true
|
||||
type: stream
|
||||
level: ERROR
|
||||
filename: '%(path)%/logs/app.log'
|
||||
syslog:
|
||||
enabled: false
|
||||
type: syslog
|
||||
level: INFO
|
||||
@@ -1,57 +0,0 @@
|
||||
my_home_server: # *DO NOT* use spaces for server name
|
||||
# Your Server type.
|
||||
type: 'jellyfin|emby|plex'
|
||||
# Your server api url.
|
||||
url: 'https://mymedia.example.com' # The URL for the media server api
|
||||
# User API Token.
|
||||
# ----
|
||||
# Jellyfin: Create API token via (Dashboard > Advanced > API keys > +)
|
||||
# Emby: Create API token via (Manage Emby server > Advanced > API keys > + New Api Key)
|
||||
# Plex: see on how to get your plex-token https://support.plex.tv/articles/204059436
|
||||
token: 'user-api-token'
|
||||
|
||||
# Set your server User ID if needed.
|
||||
# ----
|
||||
# Jellyfin : Dashboard > Server > Users > click your user > copy the userId= value
|
||||
# Emby : Manage Emby server > Server > Users > click your user > copy the userId= value
|
||||
# For Plex :
|
||||
# there is no easy way to figure out the user id, and usually there is no need to set user id for plex unless
|
||||
# you have managed users or have shared libraries.
|
||||
# to know more please read the MULTIUSER.md file.
|
||||
user: 'user-id'
|
||||
|
||||
# Server unique id.
|
||||
uuid: 'random_string' # Server unique identifier.
|
||||
|
||||
export:
|
||||
# Enable export to this server set false to disable.
|
||||
enabled: true
|
||||
import:
|
||||
# Enable import from this server set false to disable.
|
||||
enabled: true
|
||||
webhook:
|
||||
# Server specific api key to link request to this specific entry.
|
||||
token: 'random_string'
|
||||
# enable receiving webhook events from this server.
|
||||
import: true|false
|
||||
# Enable push state back to this server when watchstate tool receive webhook event.
|
||||
push: true|false
|
||||
# Require conditions to be met when webhook request is received.
|
||||
match:
|
||||
# Enable/Disable the checking of server unique id in webhook context.
|
||||
uuid: true|false
|
||||
# Enable/Disable the checking of user id in webhook context.
|
||||
user: true|false
|
||||
# options that we don't think it's needed but may help some specific cases.
|
||||
options:
|
||||
# By default, we do not import unwatched state, except in webhook context.
|
||||
# To enable importing unwatched episodes via state:import set this to true. or use --import-unwatched flag.
|
||||
importUnwatched: true|false
|
||||
# We respect the server watch date. to override the check, set this to true
|
||||
exportIgnoreDate: true|false
|
||||
# HTTP client request options.
|
||||
# Usually you should not alter any of those unless you know what you are doing.
|
||||
# remove this if you don't need them, they are here for example’s sake only.
|
||||
# for more info visit: https://symfony.com/doc/current/reference/configuration/framework.html#http-client
|
||||
client:
|
||||
http_version: 1.0 # For example can be either 1.0 or 2.0
|
||||
@@ -1,28 +0,0 @@
|
||||
FROM php:8.1-fpm-alpine
|
||||
|
||||
ENV IN_DOCKER=1
|
||||
LABEL maintainer="admin@arabcoders.org"
|
||||
|
||||
# Setup required environment
|
||||
#
|
||||
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/bin/
|
||||
|
||||
RUN mv "${PHP_INI_DIR}/php.ini-production" "${PHP_INI_DIR}/php.ini" && chmod +x /usr/bin/install-php-extensions && \
|
||||
sync && install-php-extensions pdo mbstring ctype sqlite3 json opcache xhprof pgsql mysqlnd && \
|
||||
apk add --no-cache caddy nano curl procps net-tools iproute2 shadow runuser && \
|
||||
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer && \
|
||||
mkdir -p /app /config
|
||||
|
||||
COPY ./files/entrypoint.sh /usr/bin/entrypoint-docker
|
||||
COPY ./files/Caddyfile /etc/caddy/Caddyfile
|
||||
|
||||
RUN echo '* * * * * /usr/bin/run-app-cron'>>/etc/crontabs/www-data && \
|
||||
chmod +x /usr/bin/entrypoint-docker
|
||||
|
||||
ENTRYPOINT ["/usr/bin/entrypoint-docker"]
|
||||
|
||||
WORKDIR /config
|
||||
|
||||
EXPOSE 9000 80 443
|
||||
|
||||
CMD ["php-fpm"]
|
||||
@@ -3,7 +3,7 @@ services:
|
||||
watchstate:
|
||||
container_name: watchstate
|
||||
restart: unless-stopped
|
||||
build: .
|
||||
build: ../
|
||||
environment:
|
||||
WS_UID: ${UID:-1000}
|
||||
WS_GID: ${GID:-1000}
|
||||
|
||||
12
pre_init.php
12
pre_init.php
@@ -13,3 +13,15 @@ if (!defined('BASE_PEAK_MEMORY')) {
|
||||
if (!defined('ROOT_PATH')) {
|
||||
define('ROOT_PATH', realpath(__DIR__));
|
||||
}
|
||||
|
||||
if (!defined('STDIN')) {
|
||||
define('STDIN', fopen('php://stdin', 'rb'));
|
||||
}
|
||||
|
||||
if (!defined('STDOUT')) {
|
||||
define('STDOUT', fopen('php://stdout', 'wb'));
|
||||
}
|
||||
|
||||
if (!defined('STDERR')) {
|
||||
define('STDERR', fopen('php://stderr', 'wb'));
|
||||
}
|
||||
|
||||
@@ -10,31 +10,40 @@ ini_set('display_errors', 'Off');
|
||||
|
||||
require __DIR__ . '/../pre_init.php';
|
||||
|
||||
if (!file_exists(__DIR__ . '/../vendor/autoload.php')) {
|
||||
print 'Tool is not yet. Composer dependencies is not installed.';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
set_error_handler(function (int $number, mixed $error, mixed $file, int $line) {
|
||||
$errno = $number & error_reporting();
|
||||
if (0 === $errno) {
|
||||
return;
|
||||
}
|
||||
|
||||
syslog(LOG_ERR, trim(sprintf('%s: %s (%s:%d)', $number, $error, $file, $line)));
|
||||
$message = trim(sprintf('%s: %s (%s:%d)', $number, $error, $file, $line));
|
||||
|
||||
if (env('IN_DOCKER')) {
|
||||
fwrite(STDERR, $message);
|
||||
} else {
|
||||
syslog(LOG_ERR, $message);
|
||||
}
|
||||
|
||||
exit(1);
|
||||
});
|
||||
|
||||
set_exception_handler(function (Throwable $e) {
|
||||
syslog(LOG_ERR, trim(sprintf("%s: %s (%s:%d).", get_class($e), $e->getMessage(), $e->getFile(), $e->getLine())));
|
||||
$message = trim(sprintf("%s: %s (%s:%d).", get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()));
|
||||
|
||||
if (env('IN_DOCKER')) {
|
||||
fwrite(STDERR, $message);
|
||||
} else {
|
||||
syslog(LOG_ERR, $message);
|
||||
}
|
||||
|
||||
exit(1);
|
||||
});
|
||||
|
||||
if (!file_exists(__DIR__ . '/../vendor/autoload.php')) {
|
||||
echo 'App is not initialized dependencies are missing. Please refer to docs.';
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
(new App\Libs\Initializer())->boot()->runHttp(
|
||||
function (ServerRequestInterface $request) {
|
||||
return serveHttpRequest($request);
|
||||
}
|
||||
);
|
||||
(new App\Libs\Initializer())->boot()->runHttp(fn(ServerRequestInterface $request) => serveHttpRequest($request));
|
||||
|
||||
@@ -33,12 +33,13 @@ final class Initializer
|
||||
{
|
||||
// -- Load user custom environment variables.
|
||||
(function () {
|
||||
$dataPath = env('WS_DATA_PATH', fn() => env('IN_DOCKER') ? '/config' : __DIR__ . '/../../var');
|
||||
if (file_exists(__DIR__ . '/../../.env')) {
|
||||
(new Dotenv())->usePutenv(true)->overload(__DIR__ . '/../../.env');
|
||||
}
|
||||
|
||||
$dataPath = env('WS_DATA_PATH', fn() => env('IN_DOCKER') ? '/config' : __DIR__ . '/../../var');
|
||||
if (file_exists($dataPath . '/config/.env')) {
|
||||
(new Dotenv())->usePutenv(true)->overload($dataPath . '/config/.env');
|
||||
} elseif (file_exists(__DIR__ . '/../../.env')) {
|
||||
(new Dotenv())->usePutenv(true)->overload(__DIR__ . '/../../.env');
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -58,14 +59,11 @@ final class Initializer
|
||||
{
|
||||
$this->createDirectories();
|
||||
|
||||
// -- Load user custom settings.
|
||||
(function () {
|
||||
$path = Config::get('path') . '/config/config.yaml';
|
||||
|
||||
if (file_exists($path)) {
|
||||
Config::init(function () use ($path) {
|
||||
return array_replace_recursive(Config::getAll(), Yaml::parseFile($path));
|
||||
});
|
||||
Config::init(fn() => array_replace_recursive(Config::getAll(), Yaml::parseFile($path)));
|
||||
}
|
||||
|
||||
$path = Config::get('path') . '/config/servers.yaml';
|
||||
@@ -75,16 +73,15 @@ final class Initializer
|
||||
}
|
||||
})();
|
||||
|
||||
if (Config::get('tz')) {
|
||||
date_default_timezone_set(Config::get('tz'));
|
||||
}
|
||||
date_default_timezone_set(Config::get('tz', 'UTC'));
|
||||
|
||||
$logger = Container::get(LoggerInterface::class);
|
||||
|
||||
$this->setupLoggers($logger, Config::get('logger'));
|
||||
|
||||
set_error_handler(function (int $number, mixed $error, mixed $file, int $line) {
|
||||
if (0 === error_reporting()) {
|
||||
$errno = $number & error_reporting();
|
||||
if (0 === $errno) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -134,6 +131,7 @@ final class Initializer
|
||||
EmitterInterface|null $emitter = null
|
||||
): void {
|
||||
$emitter = $emitter ?? new SapiEmitter();
|
||||
|
||||
if (null === $request) {
|
||||
$factory = new Psr17Factory();
|
||||
$request = (new ServerRequestCreator($factory, $factory, $factory, $factory))->fromGlobals();
|
||||
|
||||
Reference in New Issue
Block a user