From 271e5252d4eacbdea8394081fba63c081be1ee41 Mon Sep 17 00:00:00 2001 From: Greg Schueler Date: Mon, 20 Dec 2010 12:13:51 -0800 Subject: [PATCH 1/5] Update PATH for profile files [#130 state:resolved] --- core/src/templates/etc/profile.bat.template | 2 +- core/src/templates/etc/profile.template | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/templates/etc/profile.bat.template b/core/src/templates/etc/profile.bat.template index 14caa2c6bb8..fd87d6f9e60 100644 --- a/core/src/templates/etc/profile.bat.template +++ b/core/src/templates/etc/profile.bat.template @@ -7,6 +7,6 @@ set JAVA_HOME=@user.java_home@ :: Unsetting JRE_HOME to ensure there is no conflict with JAVA_HOME (set JRE_HOME=) -set Path=%JAVA_HOME%\bin;%RDECK_HOME%\bin;%Path% +set Path=%JAVA_HOME%\bin;%RDECK_HOME%\tools\bin;%Path% set RDECK_SSL_OPTS="-Djavax.net.ssl.trustStore=%RDECK_BASE%\etc\truststore -Djavax.net.ssl.trustStoreType=jks -Djava.protocol.handler.pkgs=com.sun.net.ssl.internal.www.protocol" \ No newline at end of file diff --git a/core/src/templates/etc/profile.template b/core/src/templates/etc/profile.template index cebe273db6e..eb6fe9217a8 100644 --- a/core/src/templates/etc/profile.template +++ b/core/src/templates/etc/profile.template @@ -7,7 +7,7 @@ export RDECK_BASE JAVA_HOME=@user.java_home@ export JAVA_HOME -PATH=$JAVA_HOME/bin:$RDECK_HOME/bin:$PATH +PATH=$JAVA_HOME/bin:$RDECK_HOME/tools/bin:$PATH export PATH if test -t 0 -a -z "$RUNDECK_CLI_TERSE" From 3ac39998e8f43d1f35f2cdee97e1985358206b81 Mon Sep 17 00:00:00 2001 From: Greg Schueler Date: Mon, 20 Dec 2010 14:22:39 -0800 Subject: [PATCH 2/5] Change Resources tab to Run. [#141 state:resolved] --- rundeckapp/grails-app/i18n/messages.properties | 2 +- rundeckapp/grails-app/views/common/_topbar.gsp | 2 +- .../grails-app/views/execution/mailNotification/status.gsp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rundeckapp/grails-app/i18n/messages.properties b/rundeckapp/grails-app/i18n/messages.properties index 8f422f38e4d..e24e28dac3b 100644 --- a/rundeckapp/grails-app/i18n/messages.properties +++ b/rundeckapp/grails-app/i18n/messages.properties @@ -31,7 +31,7 @@ default.paginate.next=next» gui.menu.Workflows=Jobs gui.menu.Events=History gui.menu.Nodes=Nodes -gui.menu.Resources=Resources +gui.menu.Run=Run gui.menu.Admin=Admin domain.ScheduledExecution.title=Job diff --git a/rundeckapp/grails-app/views/common/_topbar.gsp b/rundeckapp/grails-app/views/common/_topbar.gsp index e97a5c5bc14..72732aa07d4 100644 --- a/rundeckapp/grails-app/views/common/_topbar.gsp +++ b/rundeckapp/grails-app/views/common/_topbar.gsp @@ -121,7 +121,7 @@ function createProject(value){ - + diff --git a/rundeckapp/grails-app/views/execution/mailNotification/status.gsp b/rundeckapp/grails-app/views/execution/mailNotification/status.gsp index ac370c74105..56961eb77a4 100644 --- a/rundeckapp/grails-app/views/execution/mailNotification/status.gsp +++ b/rundeckapp/grails-app/views/execution/mailNotification/status.gsp @@ -133,7 +133,7 @@
Run Deck: - » + » » »
From 015a872ffa8d51a10218710ed78ec7cacfe857d1 Mon Sep 17 00:00:00 2001 From: Noah Campbell Date: Mon, 20 Dec 2010 16:14:29 -0800 Subject: [PATCH 3/5] Introduce JAVA_CMD variable that represents the java command to use. If JAVA_HOME is specified, this value is used in the rpm packaging. JAVA_HOME/bin/java is always used with the launcher. [#125 state:resolved] --- Makefile | 2 +- core/src/sh/dispatch | 2 +- core/src/sh/rd-check | 2 +- core/src/sh/rd-jobs | 2 +- core/src/sh/rd-project | 2 +- core/src/sh/rd-queue | 2 +- core/src/sh/rd-setup | 2 +- core/src/sh/run | 2 +- core/src/templates/etc/profile.template | 2 ++ docs/en/01-getting-started/01-chapter1.md | 2 +- docs/en/07-administration/07-chapter1.md | 11 +++++++++++ packaging/root/etc/rundeck/client/profile | 17 +++++++++++++---- 12 files changed, 35 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index db152401513..9c1e202e569 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ GARGS += -Dgrails.project.work.dir=${PWD}/rundeckapp/work GRAILS=$(GRAILS_HOME)/bin/grails $(GARGS) RUNDECK_FILES=$(shell find rundeckapp/{src,test,grails-app,scripts} -name "*.java" -o -name "*.groovy" -o -name "*.gsp") -CORE_FILES=$(shell find core/src -name "*.java" -o -path "*/src/sh/*") +CORE_FILES=$(shell find core/src -name "*.java" -o name "*.templates" -o -path "*/src/sh/*") core = core/target/rundeck-core-$(VERSION).jar war = rundeckapp/target/rundeck-$(VERSION).war diff --git a/core/src/sh/dispatch b/core/src/sh/dispatch index 8457858c8e9..eff5cde3f7b 100755 --- a/core/src/sh/dispatch +++ b/core/src/sh/dispatch @@ -35,7 +35,7 @@ fi # # Launch the cmdline tool # -exec $JAVA_HOME/bin/java ${RDECK_JVM} -classpath ${CLI_CP} \ +exec ${JAVA_CMD:-java} ${RDECK_JVM} -classpath ${CLI_CP} \ -Drdeck.base=$RDECK_BASE \ -Drdeck.home=$RDECK_HOME \ $RDECK_SSL_OPTS \ diff --git a/core/src/sh/rd-check b/core/src/sh/rd-check index 6d4978e8c60..8b6cb0aab11 100644 --- a/core/src/sh/rd-check +++ b/core/src/sh/rd-check @@ -57,7 +57,7 @@ done PATH=$JAVA_HOME/bin:$RDECK_HOME/bin:/usr/bin:/bin:/usr/sbin:/sbin export PATH -$JAVA_HOME/bin/java -Duser.java_home=$JAVA_HOME \ +exec ${JAVA_CMD:-java} -Duser.java_home=$JAVA_HOME \ -Drdeck.home=$RDECK_HOME \ -Drdeck.base=$RDECK_BASE \ -cp $cp \ diff --git a/core/src/sh/rd-jobs b/core/src/sh/rd-jobs index 4de8809261b..f258da38c94 100755 --- a/core/src/sh/rd-jobs +++ b/core/src/sh/rd-jobs @@ -35,7 +35,7 @@ fi # # Launch the cmdline tool # -exec $JAVA_HOME/bin/java ${RDECK_JVM} -classpath ${CLI_CP} \ +exec ${JAVA_CMD:-java} ${RDECK_JVM} -classpath ${CLI_CP} \ -Duser.java_home=$JAVA_HOME \ -Drdeck.base=$RDECK_BASE \ -Drdeck.home=$RDECK_HOME \ diff --git a/core/src/sh/rd-project b/core/src/sh/rd-project index c0c7d2e1fd8..18dcf2d0a41 100755 --- a/core/src/sh/rd-project +++ b/core/src/sh/rd-project @@ -35,7 +35,7 @@ fi # # Launch the cmdline tool # -exec $JAVA_HOME/bin/java ${RDECK_JVM} -classpath ${CLI_CP} \ +exec ${JAVA_CMD:-java} ${RDECK_JVM} -classpath ${CLI_CP} \ -Drdeck.base=$RDECK_BASE \ -Drdeck.home=$RDECK_HOME \ -Drdeck.traceExceptions=$RUNDECK_TRACE_EXCEPTIONS \ diff --git a/core/src/sh/rd-queue b/core/src/sh/rd-queue index f606935c1e5..07d6045cf34 100644 --- a/core/src/sh/rd-queue +++ b/core/src/sh/rd-queue @@ -35,7 +35,7 @@ fi # # Launch the cmdline tool # -exec $JAVA_HOME/bin/java ${RDECK_JVM} -classpath ${CLI_CP} \ +exec ${JAVA_CMD:-java} ${RDECK_JVM} -classpath ${CLI_CP} \ -Duser.java_home=$JAVA_HOME \ -Drdeck.base=$RDECK_BASE \ -Drdeck.home=$RDECK_HOME \ diff --git a/core/src/sh/rd-setup b/core/src/sh/rd-setup index 4e24c2d0f43..ad3886ee115 100644 --- a/core/src/sh/rd-setup +++ b/core/src/sh/rd-setup @@ -70,7 +70,7 @@ done PATH=$JAVA_HOME/bin:$RDECK_HOME/bin:/usr/bin:/bin:/usr/sbin:/sbin export PATH -$JAVA_HOME/bin/java -Dant.home=$ANT_HOME \ +exec ${JAVA_CMD:-java} -Dant.home=$ANT_HOME \ -Duser.java_home=$JAVA_HOME \ -Drdeck.home=$RDECK_HOME \ -Drdeck.base=$RDECK_BASE \ diff --git a/core/src/sh/run b/core/src/sh/run index a7dd2c0642a..03439676d68 100755 --- a/core/src/sh/run +++ b/core/src/sh/run @@ -35,7 +35,7 @@ fi # # Launch the cmdline tool # -exec $JAVA_HOME/bin/java ${RDECK_JVM} -classpath ${CLI_CP} \ +exec ${JAVA_CMD:-java} ${RDECK_JVM} -classpath ${CLI_CP} \ -Duser.java_home=$JAVA_HOME \ -Drdeck.base=$RDECK_BASE \ -Drdeck.home=$RDECK_HOME \ diff --git a/core/src/templates/etc/profile.template b/core/src/templates/etc/profile.template index eb6fe9217a8..d86fae282d7 100644 --- a/core/src/templates/etc/profile.template +++ b/core/src/templates/etc/profile.template @@ -10,6 +10,8 @@ export JAVA_HOME PATH=$JAVA_HOME/bin:$RDECK_HOME/tools/bin:$PATH export PATH +export JAVA_CMD=$JAVA_HOME/bin/java + if test -t 0 -a -z "$RUNDECK_CLI_TERSE" then RUNDECK_CLI_TERSE=true diff --git a/docs/en/01-getting-started/01-chapter1.md b/docs/en/01-getting-started/01-chapter1.md index 4b6670afc85..3b08e424cbf 100644 --- a/docs/en/01-getting-started/01-chapter1.md +++ b/docs/en/01-getting-started/01-chapter1.md @@ -106,7 +106,7 @@ runtime. The install process requires that the latest version of Java 1.6 be installed. Both the [Open JDK](http://openjdk.java.net/) and [Sun/Oracle](http://java.com/) JVMs can be used. You must have the JAVA_HOME environment variable defined -in your environment before running the installation. +in your environment before running the launcher. The RPM will use the java found on your path. See [Setting JAVA_HOME](#setting-java_home) if you want to run a different version of java. Verify your Java version to check it meets the requirement: diff --git a/docs/en/07-administration/07-chapter1.md b/docs/en/07-administration/07-chapter1.md index 4e10fa2fd3c..ff76beff0de 100644 --- a/docs/en/07-administration/07-chapter1.md +++ b/docs/en/07-administration/07-chapter1.md @@ -23,6 +23,17 @@ The script is located here: `/etc/init.d/rundeckd` /etc/initd./rundeckd stop +#### Setting JAVA_HOME + +When using the RPM, by default rundeck will use _java_ found in your path. Various RPM based +distributions provide ways of managing which version of java is found. CentOS uses +_/usr/sbin/alternatives_ and the processing of setting alternatives can be found here: http://wiki.centos.org/HowTos/JavaOnCentOS + +If you have installed a JDK or JRE in a unique directory and do not want to alter the global system +configuration, then simply setting JAVA_HOME before running any command will use the version of java +found in JAVA_HOME/bin. Updating /etc/rundeck/client/profile with JAVA_HOME is another option as +well. + ### Launcher The Launcher installation generates the script into the RDECK_BASE directory. diff --git a/packaging/root/etc/rundeck/client/profile b/packaging/root/etc/rundeck/client/profile index aa5280f0f70..736a2f306f1 100644 --- a/packaging/root/etc/rundeck/client/profile +++ b/packaging/root/etc/rundeck/client/profile @@ -4,11 +4,20 @@ export RDECK_HOME RDECK_BASE=/etc/rundeck/client export RDECK_BASE -JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64 -export JAVA_HOME +JAVA_CMD=java + +# +# If JAVA_HOME is set, then add it to home and set JAVA_CMD to use the version specified in that +# path. JAVA_HOME can be set in the rundeck profile. Or set in this file. +#JAVA_HOME= + +if [ ! -z $JAVA_HOME ]; then + PATH=$PATH:$JAVA_HOME/bin + export PATH + JAVA_CMD=$JAVA_HOME/bin/java +fi + -PATH=$PATH:$JAVA_HOME/bin -export PATH export CLI_CP=$(find /var/lib/rundeck/cli -name \*.jar -printf %p:) export BOOTSTRAP_CP=$(find /var/lib/rundeck/bootstrap -name \*.jar -printf %p:) From 57ab640567570fe360d850ed9e99985dc63da370 Mon Sep 17 00:00:00 2001 From: Greg Schueler Date: Mon, 20 Dec 2010 17:48:03 -0800 Subject: [PATCH 4/5] Fix logfile parse code to support the file encoding, but maintain byte-oriented offset counts. update tests. [#126 state:resolved] --- .../controllers/ExecutionController.groovy | 35 +++++--- .../test/unit/ExecutionControllerTests.groovy | 81 +++++++++++++++---- 2 files changed, 92 insertions(+), 24 deletions(-) diff --git a/rundeckapp/grails-app/controllers/ExecutionController.groovy b/rundeckapp/grails-app/controllers/ExecutionController.groovy index fc677a72c01..3b2994c4413 100644 --- a/rundeckapp/grails-app/controllers/ExecutionController.groovy +++ b/rundeckapp/grails-app/controllers/ExecutionController.groovy @@ -190,7 +190,7 @@ class ExecutionController { isFormatted = "true"==params.formatted } - def Map result = parseOutput(file,0,-1){ Map msgbuf -> + def Map result = parseOutput(file,0,-1,null){ Map msgbuf -> response.outputStream << (isFormatted?"${msgbuf.time} [${msgbuf.user}@${msgbuf.node} ${msgbuf.context} ${msgbuf.command}][${msgbuf.level}] ${msgbuf.mesg}" : msgbuf.mesg) true } @@ -337,7 +337,7 @@ class ExecutionController { if(bufsize<(25*1024)){ bufsize=25*1024 } - def Map result = parseOutput(file,offset,bufsize){ data -> + def Map result = parseOutput(file,offset,bufsize,null){ data -> entry << data (0==max || entry.size()0){ + stream.getChannel().position(offset) raf.seek(offset) } // log.info("starting tailExecutionOutput: offset: "+offset+", completed: "+completed) def String lSep = System.getProperty("line.separator"); def tstart=System.currentTimeMillis(); - def String line = raf.readLine() + def String line = fr.readLine() + def oline=raf.readLine() //discarded content def diff = System.currentTimeMillis()-tstart; if(bufsize > 0 && size-offset > bufsize){ @@ -518,11 +534,12 @@ class ExecutionController { buf << line + lSep } tstart=System.currentTimeMillis(); - line = raf.readLine() + line = fr.readLine()//kept + oline=raf.readLine()//discarded diff=System.currentTimeMillis()-tstart; } + fr.close() raf.close() - if(msgbuf){ //incomplete message entry. We leave it until next time unless completed==true if(completed){ diff --git a/rundeckapp/test/unit/ExecutionControllerTests.groovy b/rundeckapp/test/unit/ExecutionControllerTests.groovy index 3fdc1cc9cf9..967e0bf662e 100644 --- a/rundeckapp/test/unit/ExecutionControllerTests.groovy +++ b/rundeckapp/test/unit/ExecutionControllerTests.groovy @@ -23,15 +23,16 @@ com.jcraft.jsch.JSchException: java.net.ConnectException: Operation timed out ^^^END^^^""" fos.close() def items = [] - def result = ec.parseOutput(tf1, 0, 0) { + def result = ec.parseOutput(tf1, 0, 0,null) { assert null != it items << it true } + assertEquals "wrong items.size: "+items.size(), 9,items.size() def fsize = tf1.length() assertTrue "parsing should be completed", result.completed assertEquals "parsing should be completed", fsize, result.storeoffset - assert 9 == items.size() + //test partial metadata //11:17:34|SEVERE|greg|||localhost|Test.|error updating resources.properties: java.net.ConnectException: Connection refused assertEquals "incorrect time", "11:17:34", items[0].time @@ -81,12 +82,12 @@ Another line """ fos.close() def items = [] - def result = ec.parseOutput(tf1, 0, 0) { + def result = ec.parseOutput(tf1, 0, 0,null) { assert null != it items << it true } - assert 1 == items.size() + assertEquals "item size is not 1: " + items.size(), 1, items.size() assertFalse "parsing should not be completed", result.completed assertEquals "parsing should finish at start of second line", 87, result.storeoffset assertEquals "incorrect time", "11:17:49", items[0].time @@ -109,7 +110,7 @@ Another line """ fos.close() items = [] - result = ec.parseOutput(tf1, 0, 0) { + result = ec.parseOutput(tf1, 0, 0,null) { assert null != it items << it true @@ -130,7 +131,7 @@ Another line items = [] //parse starting at offset point of 1 byte, which should cause jump to next valid line - result = ec.parseOutput(tf1, 1, 0) { + result = ec.parseOutput(tf1, 1, 0,null) { assert null != it items << it true @@ -151,7 +152,7 @@ Another line items = [] //parse starting at offset point of 87 bytes, at start of second message - result = ec.parseOutput(tf1, 87, 0) { + result = ec.parseOutput(tf1, 87, 0,null) { assert null != it items << it true @@ -172,7 +173,7 @@ Another line items = [] //parse starting at offset point of 88 bytes, which should cause no items to be parsed - result = ec.parseOutput(tf1, 88, 0) { + result = ec.parseOutput(tf1, 88, 0,null) { assert null != it items << it true @@ -184,7 +185,7 @@ Another line items = [] //parse with only 86 bytes buffer, which should cause the second line to not be parsed - result = ec.parseOutput(tf1, 0, 86) { + result = ec.parseOutput(tf1, 0, 86,null) { assert null != it items << it true @@ -211,7 +212,7 @@ Another line fos << """^^^11:17:49|WARNING|greg|ATest|longTest|localhost|Test.ATest|One Line|extra^^^""" fos.close() def items = [] - def result = ec.parseOutput(tf1, 0, 0) { + def result = ec.parseOutput(tf1, 0, 0,null) { assert null != it items << it true @@ -231,7 +232,7 @@ Another line fos << """^^^11:17:49|WARNING|One Line|extra^^^""" fos.close() items = [] - result = ec.parseOutput(tf1, 0, 0) { + result = ec.parseOutput(tf1, 0, 0,null) { assert null != it items << it true @@ -259,7 +260,7 @@ Another line fos << """^^^11:17:49|WARNING|greg|ATest|longTest|localhost |Test.ATest|Stuff^^^""" fos.close() def items = [] - def result = ec.parseOutput(tf1, 0, 0) { + def result = ec.parseOutput(tf1, 0, 0,null) { assert null != it items << it true @@ -279,7 +280,7 @@ Another line fos << """^^^11:17:49|WARNING|greg|ATest|longTest| localhost|Test.ATest|Stuff^^^""" fos.close() items = [] - result = ec.parseOutput(tf1, 0, 0) { + result = ec.parseOutput(tf1, 0, 0,null) { assert null != it items << it true @@ -299,7 +300,7 @@ Another line fos << """^^^11:17:49|WARNING|greg|ATest| longTest |localhost|Test.ATest|Stuff^^^""" fos.close() items = [] - result = ec.parseOutput(tf1, 0, 0) { + result = ec.parseOutput(tf1, 0, 0,null) { assert null != it items << it true @@ -319,7 +320,7 @@ Another line fos << """^^^ 11:17:49 | WARNING | greg | ATest | longTest | localhost | Test.ATest |Stuff^^^""" fos.close() items = [] - result = ec.parseOutput(tf1, 0, 0) { + result = ec.parseOutput(tf1, 0, 0,null) { assert null != it items << it true @@ -334,4 +335,54 @@ Another line assertEquals "incorrect command", "longTest", items[0].command assertEquals "incorrect mesg:'${items[0].mesg}'", "Stuff\n", items[0].mesg } + + void testParseOutputUTF8() { + def ec = new ExecutionController() + assert ec != null + def File tf1 = File.createTempFile("test.", "txt") + tf1.deleteOnExit() + def fos = new OutputStreamWriter(new FileOutputStream(tf1),"UTF-8") + //File content contains UTF8, assert that the read result is correct + fos << """^^^03:21:50|INFO|admin|||centos5||/bin/sh: httpd: ??????? ?? ???????^^^ +^^^03:21:51|SEVERE|Execution failed on the following 1 nodes: [centos5]^^^ +^^^END^^^""" + fos.close() + def items = [] + def result = ec.parseOutput(tf1, 0, 0,"UTF-8") { + assert null != it + items << it + true + } + assertEquals "item size is not 1: " + items.size(), 2, items.size() + assertTrue "parsing should be completed", result.completed + assertEquals "parsing should finish with correct offset: "+result.storeoffset, 156, result.storeoffset + assertEquals "incorrect mesg:'${items[0].mesg}'", "/bin/sh: httpd: ??????? ?? ???????\n", items[0].mesg + + + } + void testParseOutputUTF16() { + def ec = new ExecutionController() + assert ec != null + def File tf1 = File.createTempFile("test.", "txt") + tf1.deleteOnExit() + def fos = new OutputStreamWriter(new FileOutputStream(tf1),"UTF-16") + //File content contains UTF8, assert that the read result is correct + fos << """^^^03:21:50|INFO|admin|||centos5||/bin/sh: httpd: ??????? ?? ???????^^^ +^^^03:21:51|SEVERE|Execution failed on the following 1 nodes: [centos5]^^^ +^^^END^^^""" + fos.close() + def items = [] + def result = ec.parseOutput(tf1, 0, 0,"UTF-16") { + assert null != it + items << it + true + } + assertEquals "item size is not 1: " + items.size(), 2, items.size() + assertTrue "parsing should be completed", result.completed + assertEquals "parsing should finish with correct offset: "+result.storeoffset, 314, result.storeoffset + assertEquals "incorrect mesg:'${items[0].mesg}'", "/bin/sh: httpd: ??????? ?? ???????\n", items[0].mesg + + + } + } From 3b794102d473b685dd90203ffba15b3d7c9191d2 Mon Sep 17 00:00:00 2001 From: Noah Campbell Date: Mon, 20 Dec 2010 22:16:05 -0800 Subject: [PATCH 5/5] Ignore temporary junit properties files. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index dd147830fed..4aea2eed859 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ rundeckapp/env.bash rundeckapp/work rundeckapp/web-app/plugins packaging/dist +core/junit*.properties