laurilehmijoki / tomcat7_rhel

Abandoned: Puppet Forge module for installing Tomcat 7 on RHEL 6
9 stars 11 forks source link

service ressource not representative #16

Closed Spredzy closed 11 years ago

Spredzy commented 11 years ago

I was reading through the module code and there is a part that does not make sense to me, would you mind explaining it ?

service { "$application_name":
    ensure     => running,
    enable     => true,
    hasstatus => true,
    require     => Package['tomcat7'],
 }

 file { "/etc/init.d/$application_name":
    ensure    => link,
    target      => "/etc/init.d/tomcat7",
    require    => Package['tomcat7'],
 }

So basically if I have a app1 and app2 if I do service app1 restart it will do the same thing as doing service app2 restart, it will restart the whole tomcat server, is this correct ?

If so, based on my understanding of puppet, the place of those two resources should be in tomcat7_rhel since tomcat7 is a singleton.

Note : If one installs only 1 application to a server that would make sense service my_app restart but if one installs 2 or 3 application on the same tomcat server, the restart action will break the other application too.

Thanks,

TomiTakussaari commented 11 years ago

In /etc/init.d/tomcat7: ...

    NAME="$(basename $0)"

...

        # Get instance specific config file
        if [ -r "/etc/sysconfig/${NAME}" ]; then
          . /etc/sysconfig/${NAME}
         fi

So, it fetches instance specific configuration from /etc/sysconfig/APPLICATION, which means that multiple tomcats can live in same server without interfering with each other.

laurilehmijoki commented 11 years ago

As TomiTakussaari pointed out, it is possible to have multiple Tomcat applications because the name of the application is inferred from the name of file.

_Tomcat7rhel creates a symbolic link from /etc/init.d/your-application into /etc/init.d/tomcat7. Now, when you invoke service your-application start, the Tomcat scripts will see NAME being bound to your-application (again, as Tomi pointed out). This is because of the symbolic linking.

In short, _Tomcat7rhel relies on symbolic links and scripts from the Tomcat RHEL package.