medicorenl / daemon-bundle
Symfony2 daemon bundle.
This package's canonical repository appears to be gone and the package has been frozen as a result. Email us for help if needed.
Installs: 1 400
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 6
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/medicorenl/daemon-bundle
Requires
- php: >=5.3.0
 - symfony/framework-bundle: >=2.2.0,<3.0-dev
 - uecode/daemon: dev-master
 
This package is not auto-updated.
Last update: 2024-06-18 01:46:56 UTC
README
DaemonBundle
A Symfony2 bundle that integrates the uecode/daemon library.
Inspired by uecode/daemon-bundle.
Installation
- 
Install Composer.
# Install Composer curl -sS https://getcomposer.org/installer | php
 - 
Add this bundle to the
composer.jsonfile of your project.php composer.phar require medicorenl/daemon-bundle dev-master
 - 
After installing, you need to require Composer's autloader in the bootstrap of your project.
// app/autoload.php $loader = require __DIR__ . '/../vendor/autoload.php';
 - 
Add the bundle to your application kernel.
// app/AppKernel.php public function registerBundles() { return array( // ... new DaemonBundle\DaemonBundle(), // ... ); }
 - 
Configure the bundle by adding parameters to the
config.ymlfile:# app/config/config.yml daemon: daemons: <command name>: appName: <name> appDir: %kernel.root_dir% appDescription: <description> logDir: %kernel.logs_dir% appPidDir: %kernel.cache_dir%/daemons/ sysMaxExecutionTime: 0 sysMaxInputTime: 0 sysMemoryLimit: 1024M appRunAsGID: 1 appRunAsUID: 1
 
Usage
- 
Create a command that extends from ExtendCommand:
<?php namespace <Application>\<Bundle>\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\InputArgument; use DaemonBundle\Command\ExtendCommand; class <Name>Command extends ExtendCommand { /** * @var string */ protected $name = '<name>'; /** * @var string */ protected $description = '<description>'; /** * @var string */ protected $help = 'Usage: <info>php app/console <name> start|stop|restart</info>'; /** * Configures command arguments. */ protected function setArguments() { } /** * Configures command options. */ protected function setOptions() { } /** * Starts asynchronous release:deploy commands for queue items. */ protected function daemonLogic() { $this->container->get('logger')->info('Daemon is running!'); $this->daemon->iterate(5); } }
 - 
Optionally create a service from your command:
<service id="<bundle alias>.command.<command alias>" class="<Application>\<Bundle>Bundle\Command\<Name>Command" />