diff --git a/config/routes.php b/config/routes.php index 5ae2236..bd0f4f0 100644 --- a/config/routes.php +++ b/config/routes.php @@ -29,5 +29,5 @@ $app->get('/', App\Action\HomePageAction::class, 'home'); $app->get('/api/ping', App\Action\PingAction::class, 'api.ping'); $app->get('/api/galleries', App\Action\ListGalleriesAction::class, 'api.galleries'); -$app->get('/api/gallery/{slug}', App\Action\ListGalleriesAction::class, 'api.gallery'); +$app->get('/api/gallery/{slug}', App\Action\GetGalleryImagesAction::class, 'api.gallery'); $app->get('/api/image/{slug}/{image}[/thumb]', App\Action\GetImageAction::class, 'api.image'); diff --git a/deploy.php b/deploy.php index bc42f1c..5b6debb 100644 --- a/deploy.php +++ b/deploy.php @@ -1,52 +1,47 @@ user('yvan') - ->forwardAgent() // You can use identity key, ssh config, or username/password to auth on the server. - ->stage('production') - ->env('deploy_path', '/mnt/domains/yvan.hu/photos/api'); +set('ssh_type', 'native'); +set('ssh_multiplexing', true); -set('repository', 'gitosis@git.fixnet.hu:angullary.git'); - -set('shared_files', [ +set('repository', 'ssh://gogs@gogs.ragnarok.yvan.hu:2206/yvan/gallery-api.git'); +set('shared_dirs', [ 'vendor', 'data/galleries', - 'config/autoload/local.php', ]); +set('writable_dirs', []); +set('keep_releases', 3); +set('default_stage', 'production'); -task('npm:install', function () { - cd('{{release_path}}/module/AngularFrontend'); - run('npm install || exit 0'); +server('prod', 'woody.fixnet.hu', 22) + ->stage('production') + ->user('yvan') + ->forwardAgent() + ->set('php_service_name', 'php7.1-fpm') + ->set('deploy_path', '/mnt/domains/yvan.hu/photos/api'); + +desc('Restart PHP-FPM service'); +task('php-fpm:restart', function () { + // The user must have rights for restart service + // /etc/sudoers: username ALL=NOPASSWD:/bin/systemctl restart php-fpm.service + run('sudo service {{php_service_name}} reload'); }); - -task('deploy:clean', [ - 'deploy:prepare', - 'deploy:release', - 'deploy:update_code', - 'deploy:shared', - 'deploy:vendors', - 'deploy:symlink', - 'cleanup', -]); +//after('deploy:symlink', 'php-fpm:restart'); task('deploy', [ 'deploy:prepare', + 'deploy:lock', 'deploy:release', 'deploy:update_code', 'deploy:shared', + 'deploy:writable', + 'deploy:vendors', + 'deploy:clear_paths', 'deploy:symlink', - 'npm:install', + 'deploy:unlock', 'cleanup', ]); -/* -task('php5-fpm:reload', function () { - run('sudo service php5-fpm reload'); -}); - -after('deploy', 'php5-fpm:reload'); -after('deploy:clean', 'php5-fpm:reload'); -after('rollback', 'php5-fpm:reload'); -*/ +after('deploy', 'success'); diff --git a/src/App/Action/HomePageAction.php b/src/App/Action/HomePageAction.php index c9ed942..e02d352 100644 --- a/src/App/Action/HomePageAction.php +++ b/src/App/Action/HomePageAction.php @@ -5,59 +5,14 @@ namespace App\Action; use Interop\Http\ServerMiddleware\DelegateInterface; use Interop\Http\ServerMiddleware\MiddlewareInterface as ServerMiddlewareInterface; use Psr\Http\Message\ServerRequestInterface; -use Zend\Diactoros\Response\HtmlResponse; use Zend\Diactoros\Response\JsonResponse; -use Zend\Expressive\Router; -use Zend\Expressive\Template; -use Zend\Expressive\Plates\PlatesRenderer; -use Zend\Expressive\Twig\TwigRenderer; -use Zend\Expressive\ZendView\ZendViewRenderer; class HomePageAction implements ServerMiddlewareInterface { - private $router; - - private $template; - - public function __construct(Router\RouterInterface $router, Template\TemplateRendererInterface $template = null) - { - $this->router = $router; - $this->template = $template; - } - public function process(ServerRequestInterface $request, DelegateInterface $delegate) { - if (! $this->template) { - return new JsonResponse([ - 'welcome' => 'Congratulations! You have installed the zend-expressive skeleton application.', - 'docsUrl' => 'https://docs.zendframework.com/zend-expressive/', - ]); - } - - $data = []; - - if ($this->router instanceof Router\AuraRouter) { - $data['routerName'] = 'Aura.Router'; - $data['routerDocs'] = 'http://auraphp.com/packages/2.x/Router.html'; - } elseif ($this->router instanceof Router\FastRouteRouter) { - $data['routerName'] = 'FastRoute'; - $data['routerDocs'] = 'https://github.com/nikic/FastRoute'; - } elseif ($this->router instanceof Router\ZendRouter) { - $data['routerName'] = 'Zend Router'; - $data['routerDocs'] = 'https://docs.zendframework.com/zend-router/'; - } - - if ($this->template instanceof PlatesRenderer) { - $data['templateName'] = 'Plates'; - $data['templateDocs'] = 'http://platesphp.com/'; - } elseif ($this->template instanceof TwigRenderer) { - $data['templateName'] = 'Twig'; - $data['templateDocs'] = 'http://twig.sensiolabs.org/documentation'; - } elseif ($this->template instanceof ZendViewRenderer) { - $data['templateName'] = 'Zend View'; - $data['templateDocs'] = 'https://docs.zendframework.com/zend-view/'; - } - - return new HtmlResponse($this->template->render('app::home-page', $data)); + return new JsonResponse([ + 'welcome' => 'Congratulations! You have reahced the end of the internet.', + ]); } } diff --git a/src/App/Action/HomePageFactory.php b/src/App/Action/HomePageFactory.php deleted file mode 100644 index cf3fe9f..0000000 --- a/src/App/Action/HomePageFactory.php +++ /dev/null @@ -1,20 +0,0 @@ -get(RouterInterface::class); - $template = $container->has(TemplateRendererInterface::class) - ? $container->get(TemplateRendererInterface::class) - : null; - - return new HomePageAction($router, $template); - } -} diff --git a/src/App/Action/PingAction.php b/src/App/Action/PingAction.php deleted file mode 100644 index c24043d..0000000 --- a/src/App/Action/PingAction.php +++ /dev/null @@ -1,16 +0,0 @@ - time()]); - } -} diff --git a/src/App/ConfigProvider.php b/src/App/ConfigProvider.php index 8a8a83b..1d6ee71 100644 --- a/src/App/ConfigProvider.php +++ b/src/App/ConfigProvider.php @@ -34,10 +34,10 @@ class ConfigProvider { return [ 'invokables' => [ - Action\PingAction::class => Action\PingAction::class, + Service\GalleryService::class => Service\GalleryService::class, + Action\HomePageAction::class => Action\HomePageAction::class, ], 'factories' => [ - Action\HomePageAction::class => Action\HomePageFactory::class, Action\ListGalleriesAction::class => Action\ListGalleriesFactory::class, Action\GetGalleryImagesAction::class => Action\GetGalleryImagesFactory::class, Action\GetImageAction::class => Action\GetImageFactory::class,