Giter Club home page Giter Club logo

codememedaemonbundle's People

Contributors

jessegreathouse avatar vatson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

codememedaemonbundle's Issues

Add codememe.daemon tag for service container config

In order to make all services configured easier and simplify dev. environments on non-pnctl compatible machines. Add DaemonicInterface for specifying start(), run(), restart() and stop() methods, configured for a daemon. Move config of daemons to service container tags.

Example command cannot be disabled

The example command that is listed when running app/console cannot be unlisted since it is part of the Bundle. This should be able to be removed from app/console in some way. Maybe making it opt-in instead?

warning: [PHP Warning] usleep(): Number of microseconds must be greater than or equal to 0

When you set the interval time to more than 2147 you will get an error: warning: [PHP Warning] usleep(): Number of microseconds must be greater than or equal to 0. As well daemon will not wait between iterations.

Similar problem is posted here:
http://pear.php.net/bugs/bug.php?id=19121

Solution is to use sleep() instead of usleep(). So the iterate method at Daemon class will looks like:

static public function iterate($sleepSeconds = 0)
{
    self::_optionObjSetup();
    if ($sleepSeconds >= 1) {
        sleep($sleepSeconds);
    } else if (is_numeric($sleepSeconds)) {
        usleep($sleepSeconds * 1000000);
    }

    clearstatcache();

    // Garbage Collection (PHP >= 5.3)
    if (function_exists('gc_collect_cycles')) {
        gc_collect_cycles();
    }

    return true;
}

Logging date format does not match default

The date format does not match the one used by Monologger. This makes it difficult to search or sort by date. Also makes it difficult to look at.

[Mar 15 13:56:07]     info: master_builder System Daemon Started at 'March 15, 2012, 1:56 pm'
[2012-03-15 13:56:09] app.INFO: running... [] []

It should say [2012-03-15 13:46:07] info: instead of [Mar 15 13:56:07] info:. Also note that not having a year in the log will mean that they will overwrite each other annually.

Commands Shouldn't Require Changing

The start, stop & restart commands should be concrete within the bundle & simply allow for:

  • Specifying a service by name via the CLI
  • All daemons are stopped/started/restarted via the CLI

Memory leaks

Overview Description

Large memory leaks are visible at short intervals iteration

Steps

  1. Setup bundle to the application;
  2. Replace CodeMeme\Bundle\CodeMemeDaemonBundle\Command\ExampleStartCommand::execute on:
<?php

    protected function execute(InputInterface $input, OutputInterface $output)
    {
      $daemon = new Daemon($this->container->getParameter('example.daemon.options'));
      $daemon->setInterval(0.001);
      $daemon->start();

      while ($daemon->isRunning()) {
          //$this->container->get('example.control')->run();
      }

      $daemon->stop();
    }
  1. Run command:
./app/console example:stop
  1. Run top(or another activity monitor) and see results;

Actual Results

Occupied memory is growing at 500kb per minute at an interval of 100 ms

Expected Results

No leakage

Platforms Tested On

Mac OS X
Darwin vatson-2.local 11.0.0 Darwin Kernel Version 11.0.0: Sat Jun 18 12:56:35 PDT 2011; root:xnu-1699.22.73~1/RELEASE_X86_64 x86_64

PHP
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Xdebug v2.1.0, Copyright (c) 2002-2010, by Derick Rethans

Additional Information

I found a reason. System_Daemon::setOptions in the Daemon::isRunning method causes memory leaks. I can not understand why we update the parameters at each iteration.

Incompatible with Symfony 2.1-BETA

You may disregaurd this as it is an incompatibility with a Beta version of Symfony, however I wanted to list the issues I have run into:

1.) There is no composer.json in your package, and you are not listed in http://packagist.org/. Both of these actions should help you gain visability to your Bundle, and aid in your installation as composer is becoming the defacto standard.

2.) Even if you get around the composer.json issue in #1, "Class Symfony\Component\HttpKernel\Util\Filesystem does not exist" is thrown. I spent a few minutes attempting to rework the code for compatibility, but it fails.

Overall it looks like a bit of work will be needed to make this 2.1 compatible.

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.