-
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
0 parents
commit 1c0b330
Showing
74 changed files
with
5,123 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
APP_NAME="NCXMediaServer" | ||
#APP_ENV=production | ||
APP_ENV=local | ||
APP_DEBUG=true | ||
APP_DOMAIN=ncxmediaserver.test | ||
APP_URL=http://${APP_DOMAIN} | ||
APP_LOG_LEVEL=debug | ||
CORS_ALLOWED_ORIGINS="http://www.clientsite.com" | ||
#APP_WEBSERVER=httpd | ||
APP_WEBSERVER=nginx | ||
|
||
######### Database setup ######### | ||
|
||
# [media] mongo db connection | ||
DB_CONNECTION_MEDIA_HOST=127.0.0.1 | ||
DB_CONNECTION_MEDIA_PORT=27017 | ||
DB_CONNECTION_MEDIA_DATABASE=ncxmedia | ||
DB_CONNECTION_MEDIA_USERNAME= | ||
DB_CONNECTION_MEDIA_PASSWORD= | ||
|
||
######### End Database setup ######### | ||
|
||
REDIS_HOST="127.0.0.1" | ||
REDIS_PORT=6379 | ||
REDIS_AUTH=false | ||
|
||
FILESYSTEM_DISK_DEFAULT="local" | ||
|
||
########### Local Disk ############# | ||
FILESYSTEM_DISK_LOCAL_PATH=/mnt/media | ||
FILESYSTEM_DISK_LOCAL_PATH_BACKUP1=/mnt/mediabkp1 | ||
FILESYSTEM_DISK_LOCAL_PATH_BACKUP2=/mnt/mediabkp2 | ||
FILESYSTEM_DISK_LOCAL_PATH_BACKUP3= | ||
FILESYSTEM_DISK_LOCAL_PATH_BACKUP4= | ||
|
||
######### End Local Disk ########## | ||
|
||
#Authorization - must match secret in Parent website | ||
JWT_SECRET=hadiIwse912khf | ||
|
||
#gd or imagick | ||
PHOTO_DRIVER=imagick | ||
|
||
########## FFMPEG paths ############ | ||
# VIDEO_NGINX_DIRNAME - This directory must be set in nginx location block for serving videos | ||
#################################### | ||
VIDEO_NGINX_DIRNAME=media | ||
VIDEO_FFMPEG_PATH=/usr/bin/ffmpeg | ||
VIDEO_FFPROBE_PATH=/usr/bin/ffprobe | ||
VIDEO_QUEUE=default |
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,50 @@ | ||
APP_NAME="NCXMediaServer" | ||
#APP_ENV=production | ||
APP_ENV=local | ||
APP_DEBUG=true | ||
APP_DOMAIN=ncxmediaserver.test | ||
APP_URL=http://${APP_DOMAIN} | ||
APP_LOG_LEVEL=debug | ||
CORS_ALLOWED_ORIGINS="http://www.clientsite.com" | ||
APP_WEBSERVER=httpd | ||
#APP_WEBSERVER=nginx | ||
|
||
######### Database setup ######### | ||
|
||
# [media] mongo db connection | ||
DB_CONNECTION_MEDIA_HOST=127.0.0.1 | ||
DB_CONNECTION_MEDIA_PORT=27017 | ||
DB_CONNECTION_MEDIA_DATABASE=ncxmedia | ||
DB_CONNECTION_MEDIA_USERNAME= | ||
DB_CONNECTION_MEDIA_PASSWORD= | ||
|
||
######### End Database setup ######### | ||
|
||
REDIS_HOST="127.0.0.1" | ||
REDIS_PORT=6379 | ||
REDIS_AUTH=false | ||
|
||
FILESYSTEM_DISK_DEFAULT="local" | ||
|
||
########### Local Disk ############# | ||
FILESYSTEM_DISK_LOCAL_PATH=C:\xampp\htdocs\ncx\ncxmediaserver\storage\app\public\media | ||
FILESYSTEM_DISK_LOCAL_PATH_BACKUP1=C:\xampp\htdocs\ncx\ncxmediaserver\storage\app\public\mediabkp1 | ||
FILESYSTEM_DISK_LOCAL_PATH_BACKUP2=C:\xampp\htdocs\ncx\ncxmediaserver\storage\app\public\mediabkp2 | ||
FILESYSTEM_DISK_LOCAL_PATH_BACKUP3= | ||
FILESYSTEM_DISK_LOCAL_PATH_BACKUP4= | ||
|
||
######### End Local Disk ########## | ||
|
||
#Authorization - must match secret in client website | ||
JWT_SECRET=hadiIwse912khf | ||
|
||
#gd or imagick | ||
PHOTO_DRIVER=gd | ||
|
||
########## FFMPEG paths ############ | ||
# VIDEO_NGINX_DIRNAME - This directory must be set in nginx location block for serving videos | ||
#################################### | ||
VIDEO_NGINX_DIRNAME=media | ||
VIDEO_FFMPEG_PATH=C:\xampp\ffmpeg\bin\ffmpeg.exe | ||
VIDEO_FFPROBE_PATH=C:\xampp\ffmpeg\bin\ffprobe.exe | ||
VIDEO_QUEUE=default |
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,8 @@ | ||
/public/storage | ||
/vendor | ||
/composer.lock | ||
/composer.phar | ||
/logs/*.log | ||
.env | ||
.phpunit.result.cache | ||
phpunit.xml |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Zvjezdan Grgurić | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,66 @@ | ||
# MediaServer | ||
|
||
Slim Framework Media Server for images and video. | ||
This image and video server does not have external provider dependencies and can be run in fully closed ecosystem. If you value your privacy this might be ideal solution for you. | ||
|
||
# Server requirements | ||
|
||
* PHP >= 7.1.3 | ||
* Fileinfo Extension | ||
* Imagick PHP extension (>=6.5.7) or GD Library (>=2.0) | ||
* ext-mongodb https://www.php.net/manual/en/mongodb.installation.pecl.php | ||
* FreeType Font support | ||
* REDIS Extension | ||
* CUrl | ||
|
||
Apache: | ||
* mod_alias | ||
* mod_rewrite | ||
|
||
Upload max size (50MB) - php.ini | ||
* post_max_size = 50M | ||
* upload_max_filesize = 50M | ||
* memory_limit = 512M | ||
|
||
# File permissions | ||
|
||
`chown -R root:daemon ../` | ||
|
||
`find storage/ -type d -exec chmod 770 {} \;` | ||
|
||
`find storage/ -type f -exec chmod 760 {} \;` | ||
|
||
# Queue and Supervisor | ||
|
||
Location of supervisor config file is /etc/supervisord.conf, at bottom of file it Include .ini, change it to .conf. | ||
|
||
`/etc/supervisord.d/mediaserver-worker.conf` | ||
|
||
``` | ||
[program:mediaserver-worker] | ||
process_name=%(program_name)s_%(process_num)02d | ||
command=/opt/php/bin/php /var/www/htdocs/mediaserver/artisan queue:run --queue=default | ||
autostart=true | ||
autorestart=true | ||
user=daemon | ||
numprocs=1 | ||
redirect_stderr=true | ||
stdout_logfile=/var/log/supervisord.log | ||
``` | ||
|
||
To enable worker run: | ||
|
||
`supervisorctl reread` | ||
|
||
`supervisorctl update` | ||
|
||
`supervisorctl start mediaserver-worker:*` | ||
|
||
# Unit Testing | ||
|
||
Windows: | ||
`.\vendor\bin\phpunit tests --testdox` | ||
|
||
Linux: | ||
`sudo -u daemon ./vendor/bin/phpunit tests --testdox` | ||
|
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,63 @@ | ||
<?php | ||
namespace Console; | ||
|
||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class ConfigCache extends Command | ||
{ | ||
protected function configure() | ||
{ | ||
$this | ||
// the name of the command (the part after "bin/console") | ||
->setName('config:cache') | ||
|
||
// the short description shown while running "php bin/console list" | ||
->setDescription('Regenerate configuration cache file.') | ||
|
||
// the full command description shown when running the command with | ||
// the "--help" option | ||
->setHelp('This command takes all configuration variables and creates compiled php file in boostrap/cache/config.php') | ||
; | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
|
||
if (file_exists(ROOT . '.env')) { | ||
$dotenv = new \Dotenv\Dotenv(ROOT); | ||
$dotenv->load(); | ||
} | ||
else | ||
die('.env file is missing'); | ||
|
||
$f = ROOT.'bootstrap'.DS.'cache'.DS.'config.php'; | ||
|
||
|
||
$settings = []; | ||
$_dir = scandir(ROOT . 'config/'); | ||
foreach($_dir as $_f) | ||
{ | ||
if (ends_with($_f,'.php')) | ||
{ | ||
|
||
$_f_arr = require ROOT . 'config/'.$_f; | ||
$settings = array_merge_recursive($settings,[basename($_f,'.php') => $_f_arr]); | ||
unset($_f_arr); | ||
unset($_f); | ||
} | ||
} | ||
unset($_f_arr); | ||
unset($_f); | ||
unset($_dir); | ||
|
||
if (is_file($f)){ | ||
$output->writeLn("<info>Configuration cache cleared!</info>"); | ||
unlink($f); | ||
} | ||
|
||
file_put_contents($f,'<?php return '.var_export($settings, true).';'); | ||
$output->writeLn("<info>Configuration cache generated!</info>"); | ||
} | ||
} |
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 @@ | ||
<?php | ||
namespace Console; | ||
|
||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
class ConfigClear extends Command | ||
{ | ||
protected function configure() | ||
{ | ||
$this | ||
// the name of the command (the part after "bin/console") | ||
->setName('config:clear') | ||
|
||
// the short description shown while running "php bin/console list" | ||
->setDescription('Delete configuration cache file.') | ||
|
||
// the full command description shown when running the command with | ||
// the "--help" option | ||
->setHelp('This command deletes configuration cache file: boostrap/cache/config.php') | ||
; | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$f = ROOT.'bootstrap'.DS.'cache'.DS.'config.php'; | ||
if (is_file($f)){ | ||
unlink($f); | ||
} | ||
$output->writeLn("<info>Configuration cache cleared!</info>"); | ||
|
||
} | ||
} |
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,68 @@ | ||
<?php | ||
//https://github.com/mariano/slim-sample-app | ||
namespace Console; | ||
use Disque\Queue\JobInterface; | ||
use Domain\Event\EventInterface; | ||
#use Infrastructure\Queue\EventJob; | ||
use Ncx\Queue\BaseJob; | ||
use Ncx\Queue\WorkerCommand; | ||
use Ncx\Queue\QueueInterface; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
use Ncx\Queue\Queue; | ||
|
||
class QueueRun extends WorkerCommand | ||
{ | ||
/** | ||
* Create instance | ||
* | ||
* @param QueueInterface $queue Queue | ||
*/ | ||
public function __construct() | ||
{ | ||
$queue = new Queue; | ||
parent::__construct($queue); | ||
} | ||
|
||
/** | ||
* Configure command | ||
* | ||
* @return void | ||
*/ | ||
protected function configure() | ||
{ | ||
parent::configure(); | ||
$this->addOption( | ||
'queue', | ||
null, | ||
InputOption::VALUE_OPTIONAL, | ||
'Set queue name to run. Defaults to default', | ||
'default' | ||
); | ||
$this->setName('queue:run') | ||
->setDescription('Process event jobs'); | ||
} | ||
|
||
protected function initialize(InputInterface $input, OutputInterface $output) | ||
{ | ||
$queueName = $input->getOption('queue'); | ||
$this->queue->setName($queueName); | ||
parent::initialize($input,$output); | ||
} | ||
|
||
/** | ||
* Work on a job | ||
* | ||
* @param JobInterface $job Job | ||
* @return void | ||
*/ | ||
protected function work(\Ncx\Queue\BaseJob $job) | ||
{ | ||
if (!($job instanceof BaseJob)) { | ||
throw new InvalidArgumentException('Not an BaseJob extended Job object'); | ||
} | ||
$job->handle(); | ||
} | ||
} |
Oops, something went wrong.