Re: Jboss module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Luca Foppiano wrote:
On Wed, 2008-03-26 at 09:23 -0400, Colin Walters wrote:
 +        for items in results:
 +            if "-Dprogram.name=run.sh" in items:
Ug.

jboss don't use pid files..I accept any suggestion about string to use
to discriminate jboss data in process list

Seems fine to me.
 +    def search_by_address(self, address, status=None):
 +        """
 +            Search istance by bind address
This should be "instance", no?  (And all the other occurences)

I don't understand. what do you means?

I think he's pointing out a spelling error.
I guess Func is trying to target Python 2.3, but what I would do is
pull subprocess.py into the distribution (works fine on 2.3), and use
it.  It's pretty much always wrong to invoke processes using /bin/sh.

This part was commented, and actually I fixed using func command module,
but there are two problems: is necessary to launch it using async method
because jboss startup is too slow and I see when I launch jboss, jboss
start as func's childs, and this can be a problem expecially if I want
to restart func.

Using it as sub_process is correct, Luca had it right. We bundle it as part of the RPM now for this reason
so we can have subprocess in 2.3, we just have it copied as sub_process.

 +        arguments = " -s jnp://"+address+":1099"
So wait, we hardcode the JNP port?  If we're not trying to support
different port numbers, why go to all the trouble of trying to detect
the bind address?  Can't we just issue a twiddle.sh command directly?

yes, but which differencies come from twiddle.sh and shutdown.sh?

as start(), stop() functions is WIP and code is dirty :)

here a corrected version (there was a trouble on port collecting, in
last version, sry).

Luca

Luca,

Can you send me this (preferably as an attachment) once you get the above squared away to the way
you want it?   Or is the above all ready to go now?

FYI -- If you send it as an attachment also include some filler text in the body of the email so mailman doesn't bounce your email (it's bad about doing that sometimes).

Thanks again!

--Michael



---
 func/minion/modules/jboss.py |   85
++++++++++++++++++++++++++++++++---------
 1 files changed, 66 insertions(+), 19 deletions(-)

diff --git a/func/minion/modules/jboss.py b/func/minion/modules/jboss.py
index 3f78ef2..e928b77 100644
--- a/func/minion/modules/jboss.py
+++ b/func/minion/modules/jboss.py
@@ -17,22 +17,14 @@ import sub_process
import codes import process
 import networktest
+import command
+from func import logger
class JBoss(func_module.FuncModule):
     version = "0.0.1"
     api_version = "0.0.1"
     description = "JBoss monitoring and control module"
-
-    def version(self):
-        """
-            Return jboss version
- TODO: implementation - """
-
-	return "version"
-
-
     def status(self):
         """
             Get jboss information
@@ -40,7 +32,8 @@ class JBoss(func_module.FuncModule):
""" processo = process.ProcessModule() results = processo.info("ax") -
+		
+	logging = logger.Logger().logger
         output = []
         for items in results:
             if "-Dprogram.name=run.sh" in items:
@@ -66,23 +59,22 @@ class JBoss(func_module.FuncModule):
 	net_status = networktest.NetworkTest()
 	results = net_status.netstat("-tupln")
- debug = []
         for string in results:#netstat_list:
             address = None
             port = None
             pid = None
try:
-                address_port = string[3]
-                pid_name = string[6]
+                address_port = string.split()[3]
+                pid_name = string.split()[6]
             except:
                 address_port = None
                 pid_name = None
-
+ if address_port != None:
                 try:
-                    address = string[3].split(":")[0]
-                    port =  int(string[3].split(":")[1])
+                    address = address_port.split(":")[0]
+                    port =  int(address_port.split(":")[1])
                 except:
                     address = None
                     port = None
@@ -95,14 +87,12 @@ class JBoss(func_module.FuncModule):
if pid != None:
                 for data in output:
-                    debug.append(data)
                     if data[0] == pid:
                         #verify address
                         if address != None:
                             if data[2] == address:
                                 data[3].append(port)
- return output @@ -183,3 +173,60 @@ class JBoss(func_module.FuncModule): return founded +'''
+    def start(self, address="127.0.0.1", istance="default"):
+        """
+ Start a jboss istance, you must specify couple + address/istance_name. ATM __call__() in server.py + doesn't support keywords.
+        """
+	# TODO: move outside this two variables
+        jboss_path="/var/lib/jboss-4.2.2.GA"
+        jboss_run_path=jboss_path+"/bin/run.sh"
+        status=self.status()
+		
+        if len(self.search_by_address(address=address,
status=status)) != 0:
+            return (-1,"Another istances listening on this address, ")
+
+       	if len(self.search_by_istance(istance=istance,
status=status)) != 0:
+            return (-1,"This istances is just istanced")
+
+        launcher ="sh "+str(jboss_run_path)+" -c "+istance+" -b
"+address
+
+	comm = command.Command()
+	comm.run(launcher)
+ + return "OK, instance "+ istance +"started on address "+address
+
+
+    def stop(self, address="127.0.0.1"):
+        """
+ Stop a jboss istance, It suppose you are using + use standard JNDI port 1099. + By default stop che localhost bind istance
+            TODO: give more flexibility
+        """
+        jboss_path="/var/lib/jboss-4.2.2.GA"
+        jboss_sd_path=jboss_path+"/bin/shutdown.sh"
+        data = self.search_by_address(address)
+
+        if len(data) == 0:
+            return (-1, "Istance on "+ address +" not running")
+ + launcher ="sh "+str(jboss_sd_path)+" -s jnp://"+address+":1099"
+
+        comm = command.Command()
+	comm.run(launcher)
+
+        return "OK, stopped istance listening address "+address
+ + def version(self):
+        """
+            Return jboss version
+ TODO: implementation + """
+
+	return "version"
+
+
+'''

_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list

[Index of Archives]     [Fedora Users]     [Linux Networking]     [Fedora Legacy List]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux