Skip to content

Better 'exec' implementation #49

@EugenMayer

Description

@EugenMayer

With then new exec_on_write feature, we probably have a conceptual issue.

Szenario:
Lets assume you have to configure a PHP FPM service. We would have a php.ini to configure ( mem, error level and thus ) a opcache config ( bucket size, timestamp check on of ) and probably a pool configuration with some error level things alligned.

Also, we would configure a memcached daemon with e.g. -m / -l configurations in /etc/memcached

--

So we would end up having exec_on_write on each template (php.ini,pool,opcache) and for memcached.conf .. 3 times restart fpm daemon and one time restart memcached daemon.

So far, so good.

Problem:

When, initial bootstrap, all configuration needs to be changed ( first write ) we will have a exec_on_write trigger for (php.ini,pool,opcache), thus we restart fpm 3 times in a row - those restarts get added and naturally things go lala land since those restarts run into a raise condition.

Solution

Short term:
Compare the exec strings of each command to run - if they match, do not run those. Basically Exec.join(' ') and then unique - run all the commands left.
I would not really go with an extra option to enable this command, exec_on_write is fairly new and the described issue would cause issues in all cases (there is no good case)

Long term:
Probably let people define service, so a

services:
   fpm:
      restart_command: ['supervisorctl','restart','fpm']
   memcached:
      restart_command: ['supervisorctl','restart','memcached']

And in the templates, instead of exec_on_write

   service_restart: 'fpm'

In the end, do not trigger several service restart. exec_on_write shall still be in place and either work as already patched or work is "run always" - but in general you do not want to run duplicate commands in a row "right after each other" - that does simply not make sense. So even then, the exec_on_write fix (short_term) make sense, it rather separates the concerns: either i want to restart a service .. only once after all templates get processed...or i want to run a specific command like "notification into hipchat" ( or whatever )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions