* cleanup

This commit is contained in:
Danyi Dávid 2017-07-21 20:26:13 +02:00
parent 64bb788110
commit 23d72b566c
6 changed files with 33 additions and 119 deletions

View File

@ -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');

View File

@ -1,52 +1,47 @@
<?php
namespace Deployer;
require 'recipe/common.php';
server('prod', 'woody.fixnet.hu', 22)
->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');

View File

@ -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.',
]);
}
}

View File

@ -1,20 +0,0 @@
<?php
namespace App\Action;
use Interop\Container\ContainerInterface;
use Zend\Expressive\Router\RouterInterface;
use Zend\Expressive\Template\TemplateRendererInterface;
class HomePageFactory
{
public function __invoke(ContainerInterface $container)
{
$router = $container->get(RouterInterface::class);
$template = $container->has(TemplateRendererInterface::class)
? $container->get(TemplateRendererInterface::class)
: null;
return new HomePageAction($router, $template);
}
}

View File

@ -1,16 +0,0 @@
<?php
namespace App\Action;
use Interop\Http\ServerMiddleware\DelegateInterface;
use Interop\Http\ServerMiddleware\MiddlewareInterface as ServerMiddlewareInterface;
use Zend\Diactoros\Response\JsonResponse;
use Psr\Http\Message\ServerRequestInterface;
class PingAction implements ServerMiddlewareInterface
{
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
{
return new JsonResponse(['ack' => time()]);
}
}

View File

@ -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,