GithubHelp home page GithubHelp logo

e-butik / codememedaemonbundle Goto Github PK

View Code? Open in Web Editor NEW

This project forked from codememe/codememedaemonbundle

1.0 15.0 0.0 118 KB

Runs Symfony2 console commands as system daemon. Wrapper for System_Daemon PEAR library

PHP 100.00%

codememedaemonbundle's Introduction

#CodeMemeDaemonBundle project status # ##Overview## CodeMemeDaemonBundle is a wrapper for the PEAR library System_Daemon which was created by Kevin Vanzonneveld.

This will enable you to install the symfony bundle and easily convert your Symfony2 console scripts into system daemons.

pcntl is required to be configured in your PHP binary to use this. On my Ubuntu server I was able to install pcntl easily with the following command:

sudo apt-get install php-5.3-pcntl-zend-server 

##System_Daemon PEAR package## System_Daemon is a PHP class that allows developers to create their own daemon applications on Linux systems. The class is focussed entirely on creating & spawning standalone daemons

More info at:

##DaemonBundle Config## Place CodeMeme\Daemonbundle in your src directory and do the following:

Deps

add the bundle to your deps configuration

[CodeMemeDaemonBundle]
    git=http://github.com/CodeMeme/CodeMemeDaemonBundle.git
    target=/bundles/CodeMeme/Bundle/CodeMemeDaemonBundle

autoload.php

Add the following to your autoload.php file:

$loader->registerNamespaces(array(
    //...
    'CodeMeme'     => __DIR__.'/../vendor/bundles',
));

appKernel.php

Add The CodeMemeDaemonBundle to your kernel bootstrap sequence

public function registerBundles()
{
    $bundles = array(
        //...
        new CodeMeme\Bundle\CodeMemeDaemonBundle\CodeMemeDaemonBundle(),
    );
    //...

    return $bundles;
}

config.yml

By Default, system daemons have a sensible configuration. If you need to change any configuration setting , you could do it by adding this configuration to your project config. Only the values that need to be changed should be added, the bundle extension will merge your daemon configs into its defaults.

app/config.yml

#CodeMemeDaemonBundle Configuration Example
code_meme_daemon:
    daemons:
        #creates a daemon using default options
        example: ~

        #an example of all the available options
        explicitexample:
            appName: example
            appDir: %kernel.root_dir%
            appDescription: Example of how to configure the DaemonBundle
            logLocation: %kernel.logs_dir%/%kernel.environment%.example.log
            authorName: Jesse Greathouse
            authorEmail: [email protected]
            appPidLocation: %kernel.cache_dir%/example/example.pid
            sysMaxExecutionTime: 0
            sysMaxInputTime: 0
            sysMemoryLimit: 1024M
            appUser: apache
            appGroup: apache
            appRunAsGID: 1000
            appRunAsUID: 1000

RunAs

You can run the daemon as a different user or group depending on what is best for your application. By default it will resolve the user and group of the user who is running the daemon from the command console, but if you want to run as a different user you can use the appUser, appGroup or appRunAsGID, appRunAsUID options. Remember if you need to run as a different user you must start the daemon as sudo or a superuser.

To find out the group and user id of a specific user you can use the following commands.

jesse@picard:~/ninethousand.org$ id -u www-data
jesse@picard:~/ninethousand.org$ id -g www-data

##Creating a Daemon## The Following links are examples of how to use a system daemon in an example project

##Usage## Once you have Daemonized your symfony Console Commands, you can simply run them from the command line like so:

jesse@picard:~/codememe$ php app/console jobqueue:start

jesse@picard:~/codememe$ php app/console jobqueue:stop

jesse@picard:~/codememe$ php app/console jobqueue:restart

codememedaemonbundle's People

Contributors

jessegreathouse avatar magnusnordlander avatar vatson avatar

Watchers

 avatar Joakim Friberg avatar Jon Gotlin avatar  avatar slava hatnuke avatar Jan Olausson avatar  avatar Eugen Kochuev avatar James Cloos avatar Patrik Wallin avatar Tatyana Stronina avatar  avatar  avatar Daniel Forster avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.