Skip to content

Commit

Permalink
package jetty tar ball and untar on demand
Browse files Browse the repository at this point in the history
added jetty glu script to tutorial package
  • Loading branch information
ypujante committed Jan 10, 2011
1 parent dca18dd commit 51de049
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 91 deletions.
8 changes: 4 additions & 4 deletions 3-TASTE-OF-GLU-TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ Loading the model
-----------------
Click on the `'Model'` tab and enter

Json Uri: http://localhost:8080/glu/sample/systems/hello-world-system.json
Json Uri: http://localhost:8080/glu/repository/systems/hello-world-system.json

and click `Load`.

Note: the console is a simple web application and is being run in a jetty container which is also used to serve static content. In a production environment it is usually *not* the way it is being done as the agents would not in general talk to the console but instead would fetch their information from a binary repository (like Artifactory) using the ivy protocol for example.

Note: you can view the model you just loaded at [http://localhost:8080/glu/sample/systems/hello-world-system.json](http://localhost:8080/glu/sample/systems/hello-world-system.json)
Note: you can view the model you just loaded at [http://localhost:8080/glu/repository/systems/hello-world-system.json](http://localhost:8080/glu/repository/systems/hello-world-system.json)

'Fixing' the issues
-------------------
Expand Down Expand Up @@ -167,15 +167,15 @@ Now the system (also known as desired state) and the current state match. There

Reloading the model
-------------------
Manually edit the file: `$GLU_TUTORIAL_ROOT/org.linkedin.glu.console-server-<version>/glu/sample/systems/hello-world-system.json`
Manually edit the file: `$GLU_TUTORIAL_ROOT/org.linkedin.glu.console-server-<version>/glu/repository/systems/hello-world-system.json`

Change the message in the very first entry to `"Hello World 3"` and save your changes

Go back to the console and reload the model:

Click on the `'Model'` tab and enter

Json Uri: http://localhost:8080/glu/sample/systems/hello-world-system.json
Json Uri: http://localhost:8080/glu/repository/systems/hello-world-system.json

and click `Load`.

Expand Down
72 changes: 40 additions & 32 deletions console/org.linkedin.glu.console-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* the License.
*/

import org.linkedin.gradle.tasks.SingleArtifactTask

apply plugin: 'org.linkedin.cmdline'
apply plugin: 'org.linkedin.release'

Expand All @@ -26,29 +28,46 @@ dependencies {
}

def jettyDistribution = "jetty-distribution-${spec.versions.jetty}"
def jettyArchive = configurations.jetty.resolve().toList()[0]

def consoleWebappProject = evaluationDependsOn(':console:org.linkedin.glu.console-webapp')
def sampleWebappProject = evaluationDependsOn(':samples:org.linkedin.glu.samples.sample-webapp')

File consoleWebapp = consoleWebappProject.tasks.getByPath('package-war').artifactFile
File sampleWebapp = sampleWebappProject.tasks.getByPath('war').archivePath

String consoleWebapp = consoleWebappProject.tasks.getByPath('package-war').artifactFile.name
def scriptProjects =
rootProject.childProjects.scripts.childProjects.values().collect { evaluationDependsOn(it.path) }

cmdline {
folders = []

dependsOn = [
':console:org.linkedin.glu.console-webapp:war'
':console:org.linkedin.glu.console-webapp:war', *scriptProjects.collect { "${it.path}:scripts"}
]

replacementTokens = [
'version': version,
'jetty.distribution': jettyDistribution,
'console.webapp': consoleWebapp
'jetty.archive': jettyArchive.name,
'console.webapp': consoleWebapp.name,
'sample.webapp': sampleWebapp.name
]

// licenses
resources << [ fileTree(dir: rootDir, includes: ['*.txt', '*.md', '*.html']) ]

// console.war
resources << [
from: consoleWebappProject.tasks.getByPath('package-war').artifactFile,
from: consoleWebapp,
into: new File(assemblePackageFile, 'glu/repository/wars'),
replaceTokens: false
]

// sample-webapp.war
resources << [
from: sampleWebapp,
into: new File(assemblePackageFile, 'glu/repository/wars'),
replaceTokens: false
]

Expand All @@ -58,33 +77,22 @@ cmdline {
into: new File(assemblePackageFile, 'keys'),
replaceTokens: false
]
}

File basePackage = project.convention.plugins.cmdline.assemblePackageFile
File jettyRoot = new File(basePackage, jettyDistribution)

/********************************************************
* task: package-assemble
* customizing package-assemble task to include jetty
********************************************************/
project.'package-assemble'.doFirst {
// fetch/untar jetty distribution
ant.untar(src: configurations.jetty.resolve().toList()[0],
dest: basePackage,
compression: 'gzip')

// remove the webapps and contexts folders
project.delete(new File(jettyRoot, "webapps"))
project.delete(new File(jettyRoot, "contexts"))
}
// jetty archive
resources << [
from: jettyArchive,
into: new File(assemblePackageFile, 'glu/repository/tgzs'),
replaceTokens: false
]

/********************************************************
* task: package-assemble
* copy the context files in jetty distribution
********************************************************/
project.'package-assemble'.doLast {
copy {
from fileTree(dir: new File(basePackage, "conf"), includes: ["*-jetty-context.xml"])
into new File(jettyRoot, 'contexts')
// scripts
scriptProjects.each { scriptProject ->
scriptProject.tasks.withType(SingleArtifactTask.class).each { t ->
resources << [
from: t.artifactFile,
into: new File(assemblePackageFile, "glu/repository/scripts/${scriptProject.name}-${scriptProject.version}"),
replaceTokens: false
]
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,16 @@
BASEDIR=`cd $(dirname $0)/.. ; pwd`
cd $BASEDIR

JAVA_OPTIONS="-Dorg.linkedin.app.name=org.linkedin.glu.console-webapp -Dorg.linkedin.glu.console.config.location=$BASEDIR/conf/glu-console-webapp.groovy -Dorg.linkedin.glu.console.keys.dir=$BASEDIR/keys -Dorg.linkedin.glu.console.root=$BASEDIR" $BASEDIR/@jetty.distribution@/bin/jetty.sh $@
JETTY_DISTRIBUTION=$BASEDIR/@jetty.distribution@

if [ ! -d $JETTY_DISTRIBUTION ]; then
echo "Setting up jetty..."
tar -zxf $BASEDIR/glu/repository/tgzs/@jetty.archive@
rm -rf $JETTY_DISTRIBUTION/contexts/*
rm -rf $JETTY_DISTRIBUTION/webapps/*
cp $BASEDIR/conf/*-jetty-context.xml $JETTY_DISTRIBUTION/contexts
chmod +x $JETTY_DISTRIBUTION/bin/*.sh
fi


JAVA_OPTIONS="-Dorg.linkedin.app.name=org.linkedin.glu.console-webapp -Dorg.linkedin.glu.console.config.location=$BASEDIR/conf/glu-console-webapp.groovy -Dorg.linkedin.glu.console.keys.dir=$BASEDIR/keys -Dorg.linkedin.glu.console.root=$BASEDIR" $JETTY_DISTRIBUTION/bin/jetty.sh $@
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Call class="org.eclipse.jetty.util.log.Log" name="debug"><Arg>Configure console-jetty-context.xml</Arg></Call>
<Set name="contextPath">/console</Set>
<Set name="war"><SystemProperty name="org.linkedin.glu.console.root"/>/@console.webapp@/</Set>
<Set name="war"><SystemProperty name="org.linkedin.glu.console.root"/>/glu/repository/wars/@console.webapp@/</Set>
</Configure>

Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"version": "1.0.0"
},
"mountPoint": "/m1/i001",
"script": "http://localhost:8080/glu/sample/scripts/HelloWorldScript.groovy"
"script": "http://localhost:8080/glu/repository/scripts/org.linkedin.glu.scrip-hello-world-@version@/HelloWorldScript.groovy"
},
{
"agent": "agent-1",
Expand All @@ -22,7 +22,7 @@
"version": "2.0.0"
},
"mountPoint": "/m2/i001",
"script": "http://localhost:8080/glu/sample/scripts/HelloWorldScript.groovy"
"script": "http://localhost:8080/glu/repository/scripts/org.linkedin.glu.scrip-hello-world-@version@/HelloWorldScript.groovy"
},
{
"agent": "agent-1",
Expand All @@ -34,7 +34,7 @@
"version": "1.0.0"
},
"mountPoint": "/m3/i001",
"script": "http://localhost:8080/glu/sample/scripts/HelloWorldScript.groovy"
"script": "http://localhost:8080/glu/repository/scripts/org.linkedin.glu.scrip-hello-world-@version@/HelloWorldScript.groovy"
},
{
"agent": "agent-1",
Expand All @@ -46,7 +46,7 @@
"version": "2.0.0"
},
"mountPoint": "/m4/i001",
"script": "http://localhost:8080/glu/sample/scripts/HelloWorldScript.groovy"
"script": "http://localhost:8080/glu/repository/scripts/org.linkedin.glu.scrip-hello-world-@version@/HelloWorldScript.groovy"
}
],
"fabric": "glu-dev-1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{
"entries": [
{
"agent": "agent-1",
"initParameters": {
"skeleton": "http://localhost:8080/glu/repository/tgzs/@jetty.archive@",
"port": 9000,
"webapps": [
{
"war": "http://localhost:8080/glu/repository/wars/@sample.webapp@",
"contextPath": "/cp1",
"monitor": "/monitor"
},
{
"war": "http://localhost:8080/glu/repository/wars/@sample.webapp@",
"contextPath": "/cp2",
"monitor": "/monitor"
}
]
},
"metadata": {
"cluster": "c1",
"container": {"name": "sample"},
"product": "product1",
"version": "1.0.0"
},
"mountPoint": "/sample/i001",
"script": "http://localhost:8080/glu/repository/scripts/org.linkedin.glu.script-jetty-@version@/JettyGluScript.groovy"
},
{
"agent": "agent-1",
"initParameters": {
"skeleton": "http://localhost:8080/glu/repository/tgzs/@jetty.archive@",
"port": 9001,
"webapps": [
{
"war": "http://localhost:8080/glu/repository/wars/@sample.webapp@",
"contextPath": "/cp1",
"monitor": "/monitor"
}
]
},
"metadata": {
"cluster": "c1",
"container": {"name": "sample"},
"product": "product1",
"version": "1.0.0"
},
"mountPoint": "/sample/i002",
"script": "http://localhost:8080/glu/repository/scripts/org.linkedin.glu.script-jetty-@version@/JettyGluScript.groovy"
},
{
"agent": "agent-1",
"initParameters": {
"skeleton": "http://localhost:8080/glu/repository/tgzs/@jetty.archive@",
"port": 9002,
"webapps": [
{
"war": "http://localhost:8080/glu/repository/wars/@sample.webapp@",
"contextPath": "/fail",
"monitor": "/monitor"
}
]
},
"metadata": {
"cluster": "c2",
"container": {"name": "sample"},
"product": "product1",
"version": "1.0.0"
},
"mountPoint": "/sample/i003",
"script": "http://localhost:8080/glu/repository/scripts/org.linkedin.glu.script-jetty-@version@/JettyGluScript.groovy"
}
],
"fabric": "glu-dev-1",
"metadata": {"product": {
"product1": {
"name": "product1",
"version": "1.0.0"
},
"product2": {
"name": "product2",
"version": "2.0.0"
}
}}
}
17 changes: 13 additions & 4 deletions scripts/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ configure(subprojects.findAll {it.name != gluScriptsTestProjectName}) {
testCompile spec.external.junit
}

processedScriptsDir = "${buildDir}/src/main/groovy"
processedScriptsDir = new File("${buildDir}/src/main/groovy")

// compiling only the pre-processed files
sourceSets.main.groovy.srcDirs = [processedScriptsDir]
Expand All @@ -58,18 +58,27 @@ configure(subprojects.findAll {it.name != gluScriptsTestProjectName}) {
// make sure that the compileGroovy task runs preCompileGroovy first
tasks.getByName('compileGroovy').dependsOn('preCompileGroovy')

def scripts = fileTree(dir: processedScriptsDir, include: '**/*.groovy')
def scriptTask = task('scripts')

def scripts = fileTree(dir: 'src/main/groovy', include: '*.groovy')

scripts.each { File scriptFile ->
def baseName = scriptFile.name - '.groovy'
task([type: SingleArtifactTask], baseName) {
artifactFile = scriptFile
task([type: SingleArtifactTask, dependsOn: 'preCompileGroovy'], baseName) {
artifactFile = new File(processedScriptsDir, scriptFile.name)
artifactReleaseInfo =
[
name: baseName,
extension: 'groovy',
configurations: ['script']
]
}

scriptTask.dependsOn(baseName)
}

// delete the processed scripts
project.'clean'.doLast {
delete processedScriptsDir
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*/
class HelloWorldGluScript
{
def version = '@script.version@'

def install = {
log.info "Install (${params.message})"
}
Expand Down
Loading

0 comments on commit 51de049

Please sign in to comment.