mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-03-31 17:15:38 +00:00
add multi-environment configuration support
This commit is contained in:
parent
74e7035123
commit
073619b461
16 changed files with 62 additions and 54 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -4,7 +4,9 @@
|
||||||
|
|
||||||
/database/yggtracker.mwb.bak
|
/database/yggtracker.mwb.bak
|
||||||
|
|
||||||
/src/config/app.php
|
/src/config/*.php
|
||||||
|
!/src/config/bootstrap.php
|
||||||
|
!/src/config/env.default.php
|
||||||
|
|
||||||
/src/public/api/manifest.json
|
/src/public/api/manifest.json
|
||||||
/src/public/api/users.json
|
/src/public/api/users.json
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,10 @@ Open trackers defined in [trackers.json](https://github.com/YGGverse/YGGtracker/
|
||||||
php8^
|
php8^
|
||||||
php-pdo
|
php-pdo
|
||||||
php-mysql
|
php-mysql
|
||||||
|
php-curl
|
||||||
|
php-memcached
|
||||||
sphinxsearch
|
sphinxsearch
|
||||||
|
memcached
|
||||||
```
|
```
|
||||||
#### Installation
|
#### Installation
|
||||||
|
|
||||||
|
|
@ -37,7 +40,7 @@ sphinxsearch
|
||||||
* The web root dir is `/src/public`
|
* The web root dir is `/src/public`
|
||||||
* Deploy the database using [MySQL Workbench](https://www.mysql.com/products/workbench) project presented in the `/database` folder
|
* Deploy the database using [MySQL Workbench](https://www.mysql.com/products/workbench) project presented in the `/database` folder
|
||||||
* Install [Sphinx Search Server](https://sphinxsearch.com)
|
* Install [Sphinx Search Server](https://sphinxsearch.com)
|
||||||
* Configuration examples presented at `/config` folder
|
* Configuration examples presented at `/config` folder. When server environment not provided, setup `env.default.php`
|
||||||
* Make sure `/src/api` folder writable
|
* Make sure `/src/api` folder writable
|
||||||
* Set up the `/src/crontab` by following [example](https://github.com/YGGverse/YGGtracker/blob/main/example/environment/crontab)
|
* Set up the `/src/crontab` by following [example](https://github.com/YGGverse/YGGtracker/blob/main/example/environment/crontab)
|
||||||
|
|
||||||
|
|
|
||||||
21
src/config/bootstrap.php
Normal file
21
src/config/bootstrap.php
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
// PHP
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
// Environment
|
||||||
|
if (!empty($_SERVER['PHP_ENV']) && file_exists(sprintf('%s/env.%s.php', __DIR__, $_SERVER['PHP_ENV'])))
|
||||||
|
{
|
||||||
|
require_once sprintf('%s/env.%s.php', __DIR__, $_SERVER['PHP_ENV']);
|
||||||
|
}
|
||||||
|
|
||||||
|
else require_once __DIR__ . '/env.default.php';
|
||||||
|
|
||||||
|
// Autoload
|
||||||
|
require_once __DIR__ . '/../../vendor/autoload.php';
|
||||||
|
|
||||||
|
// Local
|
||||||
|
require_once __DIR__ . '/../library/database.php';
|
||||||
|
require_once __DIR__ . '/../library/sphinx.php';
|
||||||
|
require_once __DIR__ . '/../library/scrapeer.php';
|
||||||
|
require_once __DIR__ . '/../library/time.php';
|
||||||
|
|
@ -23,8 +23,9 @@
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*
|
*
|
||||||
* Default configuration file example
|
* Default configuration file
|
||||||
* Production name: app.php
|
*
|
||||||
|
* For different environments, use separated env.NAME.php files
|
||||||
*
|
*
|
||||||
* Project home page
|
* Project home page
|
||||||
* https://github.com/YGGverse/YGGtracker
|
* https://github.com/YGGverse/YGGtracker
|
||||||
|
|
@ -33,9 +34,6 @@
|
||||||
* https://github.com/YGGverse/YGGtracker/issues
|
* https://github.com/YGGverse/YGGtracker/issues
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// PHP
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
// Debug
|
// Debug
|
||||||
ini_set('display_errors', '1');
|
ini_set('display_errors', '1');
|
||||||
ini_set('display_startup_errors', '1');
|
ini_set('display_startup_errors', '1');
|
||||||
|
|
@ -52,6 +50,12 @@ define('DB_PASSWORD', '');
|
||||||
define('SPHINX_HOST', '127.0.0.1');
|
define('SPHINX_HOST', '127.0.0.1');
|
||||||
define('SPHINX_PORT', 9306);
|
define('SPHINX_PORT', 9306);
|
||||||
|
|
||||||
|
// Memcached
|
||||||
|
define('MEMCACHED_PORT', 11211);
|
||||||
|
define('MEMCACHED_HOST', 'localhost');
|
||||||
|
define('MEMCACHED_NAMESPACE', 'yggtracker');
|
||||||
|
define('MEMCACHED_TIMEOUT', 60 * 5);
|
||||||
|
|
||||||
// Webapp
|
// Webapp
|
||||||
define('WEBSITE_URL', '');
|
define('WEBSITE_URL', '');
|
||||||
define('WEBSITE_NAME', 'YGGtracker');
|
define('WEBSITE_NAME', 'YGGtracker');
|
||||||
|
|
@ -8,9 +8,8 @@ if (false === sem_acquire($semaphore, true))
|
||||||
exit (PHP_EOL . 'yggtracker.crontab.export.feed process locked by another thread.' . PHP_EOL);
|
exit (PHP_EOL . 'yggtracker.crontab.export.feed process locked by another thread.' . PHP_EOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load system dependencies
|
// Bootstrap
|
||||||
require_once(__DIR__ . '/../../config/app.php');
|
require_once __DIR__ . '/../../config/bootstrap.php';
|
||||||
require_once(__DIR__ . '/../../library/database.php');
|
|
||||||
|
|
||||||
// Init Debug
|
// Init Debug
|
||||||
$debug =
|
$debug =
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
// Bootstrap
|
||||||
|
require_once __DIR__ . '/../../config/bootstrap.php';
|
||||||
|
|
||||||
// @TODO implementation for active API sync using push notifications from memcache
|
// @TODO implementation for active API sync using push notifications from memcache
|
||||||
|
|
|
||||||
|
|
@ -8,10 +8,8 @@ if (false === sem_acquire($semaphore, true)) {
|
||||||
exit (PHP_EOL . 'yggtracker.crontab.scrape process locked by another thread.' . PHP_EOL);
|
exit (PHP_EOL . 'yggtracker.crontab.scrape process locked by another thread.' . PHP_EOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load system dependencies
|
// Bootstrap
|
||||||
require_once(__DIR__ . '/../config/app.php');
|
require_once __DIR__ . '/../config/bootstrap.php';
|
||||||
require_once(__DIR__ . '/../library/database.php');
|
|
||||||
require_once(__DIR__ . '/../library/scrapeer.php');
|
|
||||||
|
|
||||||
// Init Debug
|
// Init Debug
|
||||||
$debug = [
|
$debug = [
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,8 @@ if (false === sem_acquire($semaphore, true)) {
|
||||||
exit (PHP_EOL . 'yggtracker.crontab.sitemap process locked by another thread.' . PHP_EOL);
|
exit (PHP_EOL . 'yggtracker.crontab.sitemap process locked by another thread.' . PHP_EOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load system dependencies
|
// Bootstrap
|
||||||
require_once(__DIR__ . '/../config/app.php');
|
require_once __DIR__ . '/../config/bootstrap.php';
|
||||||
require_once(__DIR__ . '/../library/database.php');
|
|
||||||
|
|
||||||
// Init Debug
|
// Init Debug
|
||||||
$debug = [
|
$debug = [
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Load dependencies
|
// Bootstrap
|
||||||
require_once (__DIR__ . '/../config/app.php');
|
require_once __DIR__ . '/../config/bootstrap.php';
|
||||||
require_once (__DIR__ . '/../library/database.php');
|
|
||||||
require_once (__DIR__ . '/../../vendor/autoload.php');
|
|
||||||
|
|
||||||
// Connect database
|
// Connect database
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Load dependencies
|
// Bootstrap
|
||||||
require_once (__DIR__ . '/../config/app.php');
|
require_once __DIR__ . '/../config/bootstrap.php';
|
||||||
require_once (__DIR__ . '/../library/database.php');
|
|
||||||
require_once (__DIR__ . '/../../vendor/autoload.php');
|
|
||||||
|
|
||||||
// Connect database
|
// Connect database
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Load dependencies
|
// Bootstrap
|
||||||
require_once (__DIR__ . '/../config/app.php');
|
require_once __DIR__ . '/../config/bootstrap.php';
|
||||||
require_once (__DIR__ . '/../library/database.php');
|
|
||||||
require_once (__DIR__ . '/../../vendor/autoload.php');
|
|
||||||
|
|
||||||
// Connect database
|
// Connect database
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Load dependencies
|
// Bootstrap
|
||||||
require_once (__DIR__ . '/../config/app.php');
|
require_once __DIR__ . '/../config/bootstrap.php';
|
||||||
require_once (__DIR__ . '/../library/database.php');
|
|
||||||
require_once (__DIR__ . '/../../vendor/autoload.php');
|
|
||||||
|
|
||||||
// Connect database
|
// Connect database
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Load dependencies
|
// Bootstrap dependencies
|
||||||
require_once (__DIR__ . '/../config/app.php');
|
require_once __DIR__ . '/../config/bootstrap.php';
|
||||||
require_once (__DIR__ . '/../library/sphinx.php');
|
|
||||||
require_once (__DIR__ . '/../library/database.php');
|
|
||||||
require_once (__DIR__ . '/../library/time.php');
|
|
||||||
require_once (__DIR__ . '/../../vendor/autoload.php');
|
|
||||||
|
|
||||||
// Connect Sphinx
|
// Connect Sphinx
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Load dependencies
|
// Bootstrap
|
||||||
require_once (__DIR__ . '/../config/app.php');
|
require_once __DIR__ . '/../config/bootstrap.php';
|
||||||
require_once (__DIR__ . '/../library/sphinx.php');
|
|
||||||
require_once (__DIR__ . '/../library/database.php');
|
|
||||||
require_once (__DIR__ . '/../library/time.php');
|
|
||||||
require_once (__DIR__ . '/../../vendor/autoload.php');
|
|
||||||
|
|
||||||
// Connect Sphinx
|
// Connect Sphinx
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,8 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Load dependencies
|
// Bootstrap
|
||||||
require_once (__DIR__ . '/../config/app.php');
|
require_once __DIR__ . '/../config/bootstrap.php';
|
||||||
require_once (__DIR__ . '/../library/time.php');
|
|
||||||
require_once (__DIR__ . '/../library/database.php');
|
|
||||||
require_once (__DIR__ . '/../../vendor/autoload.php');
|
|
||||||
|
|
||||||
// Connect database
|
// Connect database
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Load dependencies
|
// Bootstrap
|
||||||
require_once (__DIR__ . '/../config/app.php');
|
require_once __DIR__ . '/../config/bootstrap.php';
|
||||||
require_once (__DIR__ . '/../library/database.php');
|
|
||||||
require_once (__DIR__ . '/../../vendor/autoload.php');
|
|
||||||
|
|
||||||
// Connect database
|
// Connect database
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue