Skip to content

Commit

Permalink
Release 0.1.9
Browse files Browse the repository at this point in the history
- Fixes #18,#17,#16,#15
  • Loading branch information
shimberger committed Aug 12, 2011
1 parent 611bc20 commit e6d2957
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 43 deletions.
9 changes: 9 additions & 0 deletions debian/changelog
@@ -1,3 +1,12 @@
tomcat-server-manager (0.1.8~lucid) lucid; urgency=low

* Fixed bug #18: catalina.properties causing conflicts with AWT
* Fixed bug #16: Calling init script with wrong instance name => stacktrace
* Fixed bug #17: Added awt headless to parameters
* Fixed bug #15: Automatic port management does not work

-- Sebastian Himberger <sebastian@himberger.de> Aug, 12 Jul 2011 12:25:57 +0200

tomcat-server-manager (0.1.7~lucid) lucid; urgency=low tomcat-server-manager (0.1.7~lucid) lucid; urgency=low


* Fixed bug #12: Sudo Authentication failure * Fixed bug #12: Sudo Authentication failure
Expand Down
@@ -1,4 +1,4 @@
<Server port="${port.shutdown}" shutdown="${tomcat.password}"> <Server port="${tsm.port.shutdown}" shutdown="${tsm.tomcat.password}">


<GlobalNamingResources> <GlobalNamingResources>
<!-- Used by Manager webapp --> <!-- Used by Manager webapp -->
Expand All @@ -13,10 +13,10 @@
<Executor name="thread-pool" namePrefix="catalina-exec-" <Executor name="thread-pool" namePrefix="catalina-exec-"
maxThreads="150" minSpareThreads="10"/> maxThreads="150" minSpareThreads="10"/>


<Connector URIEncoding="UTF-8" executor="thread-pool" emptySessionPath="true" port="${port.http}" /> <Connector URIEncoding="UTF-8" executor="thread-pool" emptySessionPath="true" port="${tsm.port.http}" />


<!-- This is here for compatibility only, not required --> <!-- This is here for compatibility only, not required -->
<Connector URIEncoding="UTF-8" executor="thread-pool" emptySessionPath="true" port="${port.https}" protocol="AJP/1.3" /> <Connector URIEncoding="UTF-8" executor="thread-pool" emptySessionPath="true" port="${tsm.port.ajp}" protocol="AJP/1.3" />


<Engine name="Catalina" defaultHost="localhost"> <Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
Expand Down
Expand Up @@ -34,6 +34,7 @@ wrapper.java.additional.9=-Dcom.sun.management.jmxremote.authenticate="false"
wrapper.java.additional.10=-Dcom.sun.management.jmxremote.ssl="false" wrapper.java.additional.10=-Dcom.sun.management.jmxremote.ssl="false"
wrapper.java.additional.11=-Dorg.tanukisoftware.wrapper.WrapperManager.mbean=true wrapper.java.additional.11=-Dorg.tanukisoftware.wrapper.WrapperManager.mbean=true
wrapper.java.additional.12=-Dorg.tanukisoftware.wrapper.WrapperManager.mbean.testing=false wrapper.java.additional.12=-Dorg.tanukisoftware.wrapper.WrapperManager.mbean.testing=false
wrapper.java.additional.13=-Djava.awt.headless=true
wrapper.java.additional.14=-XX:MaxPermSize=%JAVA_MAXPERMSIZE% wrapper.java.additional.14=-XX:MaxPermSize=%JAVA_MAXPERMSIZE%


# Initial Java Heap Size (in MB) # Initial Java Heap Size (in MB)
Expand Down
93 changes: 53 additions & 40 deletions usr/sbin/tomcat-server-manager
Expand Up @@ -15,7 +15,7 @@ import subprocess


def add_key_to_list(key,thedict,thelist): def add_key_to_list(key,thedict,thelist):
if key in thedict: if key in thedict:
thelist += thedict[key] thelist.append(str(thedict[key]))


def args_as_dict(args): def args_as_dict(args):
args_dict = {} args_dict = {}
Expand Down Expand Up @@ -68,11 +68,11 @@ class InstanceManager:
def get_instance_ports(self,instance): def get_instance_ports(self,instance):
ports = [] ports = []
properties = self.read_instance_properties(instance) properties = self.read_instance_properties(instance)
add_key_to_list("port.jmx",properties,ports) add_key_to_list("tsm.port.jmx",properties,ports)
add_key_to_list("port.ajp",properties,ports) add_key_to_list("tsm.port.ajp",properties,ports)
add_key_to_list("port.http",properties,ports) add_key_to_list("tsm.port.http",properties,ports)
add_key_to_list("port.https",properties,ports) add_key_to_list("tsm.port.https",properties,ports)
add_key_to_list("port.shutdown",properties,ports) add_key_to_list("tsm.port.shutdown",properties,ports)
return ports return ports




Expand All @@ -83,32 +83,30 @@ class InstanceManager:
used_ports = [] used_ports = []
for instance in self.available_instances(): for instance in self.available_instances():
used_ports += self.get_instance_ports(instance) used_ports += self.get_instance_ports(instance)
avail_ports = [p for p in all_ports if p not in used_ports] avail_ports = [p for p in all_ports if str(p) not in used_ports]
print avail_ports
if len(avail_ports) < num: if len(avail_ports) < num:
raise Exception("Not enough free ports available") raise Exception("Not enough free ports available")
assigned_ports = [] return avail_ports
for port in avail_ports:
assigned_ports.append(port)
return assigned_ports




def instance_environment(self,instance): def instance_environment(self,instance):
properties = self.read_instance_properties(instance) properties = self.read_instance_properties(instance)
return { return {
"CATALINA_BASE": os.path.join(self.var_root,instance), "CATALINA_BASE": os.path.join(self.var_root,instance),
"CATALINA_HOME": os.path.join(self.config_path,"tomcat-versions",properties["tomcat.version"],"catalina-home"), "CATALINA_HOME": os.path.join(self.config_path,"tomcat-versions",properties["tsm.tomcat.version"],"catalina-home"),
"APP_NAME": "tomcat-"+instance, "APP_NAME": "tomcat-"+instance,
"APP_LONG_NAME": "Tomcat instance " + instance, "APP_LONG_NAME": "Tomcat instance " + instance,
"WRAPPER_CONF": os.path.join(self.instances_path,instance,"conf","wrapper.conf"), "WRAPPER_CONF": os.path.join(self.instances_path,instance,"conf","wrapper.conf"),
"PIDDIR": os.path.join(self.var_root,instance,"run"), "PIDDIR": os.path.join(self.var_root,instance,"run"),
"RUN_AS_USER": properties["instance.user"], "RUN_AS_USER": properties["tsm.instance.user"],
"CATALINA_DEBUG": properties["tomcat.debug"], "CATALINA_DEBUG": properties["tsm.tomcat.debug"],
"PRIORITY": "", "PRIORITY": "",
"JAVA_HOME": properties["java.home"], "JAVA_HOME": properties["tsm.java.home"],
"JAVA_JMXPORT": properties["port.jmx"], "JAVA_JMXPORT": properties["tsm.port.jmx"],
"JAVA_MAXMEMORY": properties["java.memory.max"], "JAVA_MAXMEMORY": properties["tsm.java.memory.max"],
"JAVA_INITMEMORY": properties["java.memory.init"], "JAVA_INITMEMORY": properties["tsm.java.memory.init"],
"JAVA_MAXPERMSIZE": properties["java.memory.maxPermSize"], "JAVA_MAXPERMSIZE": properties["tsm.java.memory.maxPermSize"],
"WAIT_AFTER_STARTUP": '0', "WAIT_AFTER_STARTUP": '0',
"SHELL": '/bin/dash', "SHELL": '/bin/dash',
} }
Expand Down Expand Up @@ -232,6 +230,14 @@ class Command:
def ensure_lock(self): def ensure_lock(self):
pass pass



class InstanceCommand(Command):

def ensure_instance_does_exist(self,instance_name):
if not instance_name in self.instance_manager.available_instances():
self.fail("An instance with the name " + instance_name + " does not exist")


class ListCommand(Command): class ListCommand(Command):


_name = "list-instances" _name = "list-instances"
Expand Down Expand Up @@ -276,23 +282,23 @@ class CreateInstanceCommand(Command):


def generate_config(self,args): def generate_config(self,args):
config = "# Network configuration:" + "\n" config = "# Network configuration:" + "\n"
config += "port.jmx=" + args["jmx-port"] + "\n" config += "tsm.port.jmx=" + args["jmx-port"] + "\n"
config += "port.ajp=" + args["ajp-port"] + "\n" config += "tsm.port.ajp=" + args["ajp-port"] + "\n"
config += "port.http=" + args["http-port"] + "\n" config += "tsm.port.http=" + args["http-port"] + "\n"
config += "port.https=" + args["https-port"] + "\n" config += "tsm.port.https=" + args["https-port"] + "\n"
config += "port.shutdown=" + args["shutdown-port"] + "\n" config += "tsm.port.shutdown=" + args["shutdown-port"] + "\n"
config += "# Tomcat configuration: \n" config += "# Tomcat configuration: \n"
config += "tomcat.version=" + args["tomcat-version"] + "\n" config += "tsm.tomcat.version=" + args["tomcat-version"] + "\n"
config += "tomcat.debug=" + args["tomcat-debug"] + "\n" + "\n" config += "tsm.tomcat.debug=" + args["tomcat-debug"] + "\n" + "\n"
config += "tomcat.password=" + args["shutdown-password"] + "\n" + "\n" config += "tsm.tomcat.password=" + args["shutdown-password"] + "\n" + "\n"
config += "# Java configuration: \n" config += "# Java configuration: \n"
config += "java.home=" + args["java-home"] + "\n" config += "tsm.java.home=" + args["java-home"] + "\n"
config += "java.memory.maxPermSize=" + args["java-memory-max-perm-size"] + "\n" config += "tsm.java.memory.maxPermSize=" + args["java-memory-max-perm-size"] + "\n"
config += "java.memory.max=" + args["java-memory-max-size"] + "\n" config += "tsm.java.memory.max=" + args["java-memory-max-size"] + "\n"
config += "java.memory.init=" + args["java-memory-init-size"] + "\n" config += "tsm.java.memory.init=" + args["java-memory-init-size"] + "\n"
config += "# Instance configuration: " + "\n" config += "# Instance configuration: " + "\n"
config += "instance.user=" + args["instance-user"] + "\n" config += "tsm.instance.user=" + args["instance-user"] + "\n"
config += "instance.enabled=true" + "\n" + "\n" config += "tsm.instance.enabled=true" + "\n" + "\n"
config += "# Internal (do not remove) :\n" config += "# Internal (do not remove) :\n"
config += "package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.,sun.beans.package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper." + "\n" config += "package.access=sun.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper.,sun.beans.package.definition=sun.,java.,org.apache.catalina.,org.apache.coyote.,org.apache.tomcat.,org.apache.jasper." + "\n"
config += "common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar" + "\n" config += "common.loader=${catalina.home}/lib,${catalina.home}/lib/*.jar" + "\n"
Expand Down Expand Up @@ -372,73 +378,80 @@ class ListVersionConfigsCommand(Command):
for v in self.instance_manager.available_version_configs(args["version"],args["config"]): for v in self.instance_manager.available_version_configs(args["version"],args["config"]):
print v print v


class StartConsoleCommand(Command): class StartConsoleCommand(InstanceCommand):


_name = "start-console" _name = "start-console"
_help = "Starts the instance in console mode" _help = "Starts the instance in console mode"
_required_args = ["instance-name"] _required_args = ["instance-name"]


def execute(self,args): def execute(self,args):
self.ensure_instance_does_exists(args["instance-name"])
os.environ.update(self.instance_manager.instance_environment(args["instance-name"])) os.environ.update(self.instance_manager.instance_environment(args["instance-name"]))
os.system("/usr/bin/java-service-wrapper-init-script console") os.system("/usr/bin/java-service-wrapper-init-script console")


class StartInstanceCommand(Command): class StartInstanceCommand(InstanceCommand):


_name = "start-instance" _name = "start-instance"
_help = "Starts the instance" _help = "Starts the instance"
_required_args = ["instance-name"] _required_args = ["instance-name"]


def execute(self,args): def execute(self,args):
self.ensure_instance_does_exist(args["instance-name"])
os.environ.update(self.instance_manager.instance_environment(args["instance-name"])) os.environ.update(self.instance_manager.instance_environment(args["instance-name"]))
os.system("/usr/bin/java-service-wrapper-init-script start") os.system("/usr/bin/java-service-wrapper-init-script start")


class StopInstanceCommand(Command): class StopInstanceCommand(InstanceCommand):


_name = "stop-instance" _name = "stop-instance"
_help = "Stops the instance" _help = "Stops the instance"
_required_args = ["instance-name"] _required_args = ["instance-name"]


def execute(self,args): def execute(self,args):
self.ensure_instance_does_exist(args["instance-name"])
os.environ.update(self.instance_manager.instance_environment(args["instance-name"])) os.environ.update(self.instance_manager.instance_environment(args["instance-name"]))
os.system("/usr/bin/java-service-wrapper-init-script stop") os.system("/usr/bin/java-service-wrapper-init-script stop")


class RestartInstanceCommand(Command): class RestartInstanceCommand(InstanceCommand):


_name = "restart-instance" _name = "restart-instance"
_help = "Restarts the instance" _help = "Restarts the instance"
_required_args = ["instance-name"] _required_args = ["instance-name"]


def execute(self,args): def execute(self,args):
self.ensure_instance_does_exist(args["instance-name"])
os.environ.update(self.instance_manager.instance_environment(args["instance-name"])) os.environ.update(self.instance_manager.instance_environment(args["instance-name"]))
os.system("/usr/bin/java-service-wrapper-init-script restart") os.system("/usr/bin/java-service-wrapper-init-script restart")


class CondrestartInstanceCommand(Command): class CondrestartInstanceCommand(InstanceCommand):


_name = "condrestart-instance" _name = "condrestart-instance"
_help = "Condretarts the instance" _help = "Condretarts the instance"
_required_args = ["instance-name"] _required_args = ["instance-name"]


def execute(self,args): def execute(self,args):
self.ensure_instance_does_exist(args["instance-name"])
os.environ.update(self.instance_manager.instance_environment(args["instance-name"])) os.environ.update(self.instance_manager.instance_environment(args["instance-name"]))
os.system("/usr/bin/java-service-wrapper-init-script condrestart") os.system("/usr/bin/java-service-wrapper-init-script condrestart")


class StatusInstanceCommand(Command): class StatusInstanceCommand(InstanceCommand):


_name = "status-instance" _name = "status-instance"
_help = "Retrieves the status of the instance" _help = "Retrieves the status of the instance"
_required_args = ["instance-name"] _required_args = ["instance-name"]


def execute(self,args): def execute(self,args):
self.ensure_instance_does_exist(args["instance-name"])
os.environ.update(self.instance_manager.instance_environment(args["instance-name"])) os.environ.update(self.instance_manager.instance_environment(args["instance-name"]))
os.system("/usr/bin/java-service-wrapper-init-script status") os.system("/usr/bin/java-service-wrapper-init-script status")


class DumpInstanceCommand(Command): class DumpInstanceCommand(InstanceCommand):


_name = "dump-instance" _name = "dump-instance"
_help = "Dumps the status of the instance" _help = "Dumps the status of the instance"
_required_args = ["instance-name"] _required_args = ["instance-name"]


def execute(self,args): def execute(self,args):
self.ensure_instance_does_exist(args["instance-name"])
os.environ.update(self.instance_manager.instance_environment(args["instance-name"])) os.environ.update(self.instance_manager.instance_environment(args["instance-name"]))
os.system("/usr/bin/java-service-wrapper-init-script dump") os.system("/usr/bin/java-service-wrapper-init-script dump")


Expand Down

0 comments on commit e6d2957

Please sign in to comment.