0

我有以下 Tomcat 小类的代码,该类运行良好,但脚本末尾的服务没有启动。任何指导都会很棒。我不知道为什么服务不会启动。

Tomcat6类的内容

# Class: tomcat6
#
# This module manages tomcat6
#
# Parameters: none
#
# Actions:
#
# Requires: see Modulefile
#
# Sample Usage:
#
class tomcat6 ( $parentdir               = '/usr/share',
                $tomcat_version          = '6.0.37',
                $tomcat_major_version    = '6',
                $digest_string           = '171d255cd60894b29a41684ce0ff93a8',
                $tomcat_exe              = 'tomcat6/tomcat.erb',
                $java_home               = '/usr/java/latest',
                $jvm_route               = 'jvm1',
                $shutdown_password       = 'SHUTDOWN',
                $admin_port              = 8005,
                $http_port               = 8080,
                $tomcat_user             = 'root',
                $tomcat_group            = 'root',
                $admin_user              = 'tomcat',
                $admin_password          = 'tomcat'
             ) {

  $basedir     = "${parentdir}/apache-tomcat-6.0.37"

  file {'/installs':
    ensure  => 'directory',
    source  => 'puppet:///modules/tomcat6/',
    recurse => 'remote',
    owner   => 'root',
    group   => 'root',
    mode    => '0755',
  }

  exec { 'tomcat_untar':
    command => 'tar -zxvf /installs/apache-tomcat-6.0.37.tar.gz -C /usr/share/',
    cwd     => '/usr/share/',
    creates => "/usr/share/apache-tomcat-6.0.37",
    path    => ["/bin"],
    require =>  [File["/installs"]]
  }

  file { "/etc/init.d/tomcat":
        ensure => present,
        owner  => root,
        group  => root,
        mode   => 0755,
        content => template($tomcat_exe),
        require => Exec["tomcat_untar"]
  }

    service { "tomcat":
        ensure  => "running",
        enable  => "true",
        require => File["/etc/init.d/tomcat"]
    } 
}

tomcat.erb 的内容

#!/bin/bash
# description: Tomcat Start Stop Restart
# processname: tomcat
# chkconfig: 234 20 80
JAVA_HOME=/usr/java/jdk1.6.0_26
export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH
export PATH
CATALINA_HOME=/usr/share/apache-tomcat-6.0.37

case $1 in
start)
sh $CATALINA_HOME/bin/startup.sh
;;
stop)
sh $CATALINA_HOME/bin/shutdown.sh
;;
restart)
sh $CATALINA_HOME/bin/shutdown.sh
sh $CATALINA_HOME/bin/startup.sh
;;
esac
exit 0
4

1 回答 1

0

Puppet 执行 /etc/init.d/tomcat 状态以查看服务是否正在运行。如果服务停止后它没有得到正确的返回状态,它将不会尝试启动它。

http://docs.puppetlabs.com/references/latest/type.html#service

查看 hasstatus。

另一种方法是让 Puppet grep 通过进程表,并将 'pattern' 和 'hasstatus' 设置为 false。

于 2013-08-08T08:16:33.163 回答