-
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
sergiu
committed
Jun 12, 2020
0 parents
commit 7cb3bb3
Showing
76 changed files
with
3,450 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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 DotKernel | ||
|
||
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,157 @@ | ||
# pingu | ||
Application for Queue , using swoole and Lamins // Mezzio | ||
|
||
# Installing DotKernel `pingu` | ||
|
||
- [Installing DotKernel `pingu`](#installing-dotkernel-pingu) | ||
- [Installation](#installation) | ||
- [Composer](#composer) | ||
- [Choose a destination path for DotKernel `pingu` installation](#choose-a-destination-path-for-dotkernel-pingu-installation) | ||
- [Installing the `pingu` Composer package](#installing-the-pingu-composer-package) | ||
- [Installing DotKernel pingu](#installing-dotkernel-pingu) | ||
- [Configuration - First Run](#configuration---first-run) | ||
- [Testing (Running)](#testing-running) | ||
|
||
### Composer | ||
|
||
Installation instructions: | ||
|
||
- [Composer Installation - Linux/Unix/OSX](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx) | ||
- [Composer Installation - Windows](https://getcomposer.org/doc/00-intro.md#installation-windows) | ||
|
||
> If you have never used composer before make sure you read the [`Composer Basic Usage`](https://getcomposer.org/doc/01-basic-usage.md) section in Composer's documentation | ||
## Choosing an installation path for DotKernel `pingu` | ||
|
||
Example: | ||
|
||
- absolute path `/var/www/pingu` | ||
- or relative path `pingu` (equivalent with `./pingu`) | ||
|
||
## Installing DotKernel `pingu` | ||
|
||
After choosing the path for DotKernel (`pingu` will be used for the remainder of this example) it must be installed. | ||
|
||
#### Installing DotKernel `pingu` using git clone | ||
|
||
This method requires more manual input, but it ensures that the default branch is installed, even if it is not released. Run the following command: | ||
|
||
```bash | ||
$ git clone https://github.com/dotkernel/pingu.git . | ||
``` | ||
|
||
The dependencies have to be installed separately, by running this command | ||
```bash | ||
$ composer install | ||
``` | ||
|
||
The setup asks for configuration settings regarding injections (type `0` and hit `enter`) and a confirmation to use this setting for other packages (type `y` and hit `enter`) | ||
|
||
## Configuration - First Run | ||
|
||
- Remove the `.dist` extension from the files `config/autoload/local.php.dist`, `config/autoload/mail.local.php.dist`, `config/autoload/notification.local.php.dist`, `config/autoload/redis.local.php.dist`, `config/autoload/swoole.local.php.dist` | ||
- Edit `config/autoload/local.php` according to your dev machine and fill in the `database` configuration | ||
- Edit `config/autoload/notification.php` by filling the 'protocol' and 'host' configuration | ||
- Add smtp credentials in `config/autoload/mail.local.php` if you want your application to send mails on registration etc. | ||
- Create `data/logs` folder and leave it empty | ||
|
||
> Charset recommendation: utf8mb4_general_ci | ||
## Testing (Running) | ||
|
||
Note: **Do not enable dev mode in production** | ||
|
||
- Run the following commands in your project's directory ( in different tabs ): | ||
|
||
```bash | ||
$ redis-cli | ||
$ php bin/dot-swoole start | ||
$ vendor/bin/qjitsu work | ||
$ vendor/bin/qjitsu scheduler:run --interval=1 | ||
``` | ||
|
||
> Tip: use --interval=1 on dev only | ||
**NOTE:** | ||
If you are still getting exceptions or errors regarding some missing services, try running the following command | ||
|
||
```bash | ||
$ php bin/clear-config-cache.php | ||
``` | ||
|
||
> If `config-cache.php` is present that config will be loaded regardless of the `ConfigAggregator::ENABLE_CACHE` in `config/autoload/mezzio.global.php` | ||
## Daemons (services) files content | ||
```bash | ||
app-main.service | ||
[Unit] | ||
Description=pingu startup service | ||
StartLimitIntervalSec=1 | ||
|
||
[Service] | ||
#The dummy program will exit | ||
Type=oneshot | ||
ExecStart=/bin/true | ||
RemainAfterExit=yes | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
``` | ||
|
||
```bash | ||
app-queue.service | ||
[Unit] | ||
Description=Queue startup service | ||
After=mysqld.service | ||
PartOf=app-main.service | ||
StartLimitIntervalSec=1 | ||
|
||
[Service] | ||
Type=simple | ||
Restart=always | ||
RestartSec=1 | ||
User=root | ||
ExecStart=/usr/bin/php /var/www/html/app-directory/vendor/bin/qjitsu work | ||
|
||
[Install] | ||
WantedBy=app-main.service | ||
``` | ||
|
||
```bash | ||
app-queue-scheduler.service | ||
[Unit] | ||
Description=Queue scheduler startup service | ||
After=mysqld.service | ||
PartOf=app-main.service | ||
StartLimitIntervalSec=1 | ||
|
||
[Service] | ||
Type=simple | ||
Restart=always | ||
RestartSec=1 | ||
User=root | ||
ExecStart=/usr/bin/php /var/www/html/app-directory/vendor/bin/qjitsu scheduler:run --interval=1 | ||
|
||
[Install] | ||
WantedBy=app-main.service | ||
``` | ||
|
||
```bash | ||
app-swoole.service | ||
[Unit] | ||
Description=pingu startup service | ||
After=mysqld.service | ||
PartOf=app-main.service | ||
StartLimitIntervalSec=1 | ||
|
||
[Service] | ||
Type=simple | ||
Restart=always | ||
RestartSec=1 | ||
User=root | ||
ExecStart=/usr/bin/php /var/www/html/app-directory/bin/dot-swoole start | ||
ExecStop=/usr/bin/php /var/www/html/app-directory/bin/dot-swoole stop | ||
|
||
[Install] | ||
WantedBy=app-main.service | ||
``` |
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,48 @@ | ||
<?php | ||
/** | ||
* Script for clearing the configuration cache. | ||
* | ||
* Can also be invoked as `composer clear-config-cache`. | ||
* | ||
* @see https://github.com/mezzio/mezzio-skeleton for the canonical source repository | ||
* @copyright Copyright (c) 2017 Zend Technologies USA Inc. (http://www.zend.com) | ||
* @license https://github.com/mezzio/mezzio-skeleton/blob/master/LICENSE.md New BSD License | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
chdir(__DIR__ . '/../'); | ||
|
||
require 'vendor/autoload.php'; | ||
|
||
$config = include 'config/config.php'; | ||
|
||
if (! isset($config['config_cache_path'])) { | ||
echo "No configuration cache path found" . PHP_EOL; | ||
exit(0); | ||
} | ||
|
||
if (! file_exists($config['config_cache_path'])) { | ||
printf( | ||
"Configured config cache file '%s' not found%s", | ||
$config['config_cache_path'], | ||
PHP_EOL | ||
); | ||
exit(0); | ||
} | ||
|
||
if (false === unlink($config['config_cache_path'])) { | ||
printf( | ||
"Error removing config cache file '%s'%s", | ||
$config['config_cache_path'], | ||
PHP_EOL | ||
); | ||
exit(1); | ||
} | ||
|
||
printf( | ||
"Removed configured config cache file '%s'%s", | ||
$config['config_cache_path'], | ||
PHP_EOL | ||
); | ||
exit(0); |
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 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
/** | ||
* Start, stop, and reload the server. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Dot\Swoole\Command; | ||
|
||
use Symfony\Component\Console\Application as CommandLine; | ||
use Symfony\Component\Console\CommandLoader\ContainerCommandLoader; | ||
|
||
use function chdir; | ||
use function file_exists; | ||
use function fwrite; | ||
use function is_dir; | ||
use function sprintf; | ||
use function strstr; | ||
use function str_repeat; | ||
|
||
use const PHP_EOL; | ||
use const STDERR; | ||
|
||
// Setup/verify autoloading | ||
$depth = 1; | ||
while ($depth <= 4) { | ||
$dir = sprintf('%s/%s', __DIR__, str_repeat('../', $depth)); | ||
if (is_dir($dir . 'vendor')) { | ||
$cwd = $dir; | ||
} | ||
|
||
$depth += 1; | ||
} | ||
|
||
if (! isset($cwd)) { | ||
fwrite(STDERR, 'Cannot locate autoloader; please run "composer install"' . PHP_EOL); | ||
exit(1); | ||
} | ||
|
||
chdir($cwd); | ||
|
||
require 'vendor/autoload.php'; | ||
|
||
// Setup/verify application DI container | ||
$containerFile = sprintf('%s/config/container.php', $cwd); | ||
if (! file_exists($containerFile)) { | ||
fwrite(STDERR, sprintf( | ||
'No container file (%s) detected; are you in an Expressive application?%s', | ||
$containerFile, | ||
PHP_EOL | ||
)); | ||
exit(1); | ||
} | ||
|
||
$container = require $containerFile; | ||
|
||
// Create, populate, and run the CLI tooling | ||
$commandLine = new CommandLine('Dotkernel swoole web server'); | ||
$commandLine->setAutoExit(true); | ||
$commandLine->setCommandLoader(new ContainerCommandLoader($container, [ | ||
'reload' => ReloadCommand::class, | ||
'start' => StartCommand::class, | ||
'status' => StatusCommand::class, | ||
'stop' => StopCommand::class, | ||
])); | ||
|
||
$commandLine->run(); |
Oops, something went wrong.