Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes related to making zerotocloud work with the latest Karyon #9

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 32 additions & 24 deletions karyon/build.gradle
@@ -1,38 +1,47 @@

import zerotocloud.*
task cloneRepo(type: CloneRepo) {
repository = 'https://github.com/Netflix/karyon.git'
repository = 'https://github.com/Netflix/karyon.git'

}

task patchRepo {
dependsOn 'cloneRepo'
dependsOn 'cloneRepo'
doFirst {
def app = new File(cloneRepo.gitDir, 'karyon-examples/hello-netflix-oss/src/main/java/com/netflix/hellonoss/server/HelloWorldApp.java')
def app = new File(cloneRepo.gitDir, 'karyon-examples/src/main/java/com/netflix/karyon/examples/hellonoss/server/jersey/JerseyHelloWorldApp.java')
def contents = app.text
app.withWriter { out ->
out << contents
.replace('//, KaryonEurekaModule.class', ', KaryonEurekaModule.class')
// It's impossible to test REST calls from a browser if a HTTP Header is required.
.replace('interceptorSupport.forUri("/hello").interceptIn(AuthInterceptor.class);', '//interceptorSupport.forUri("/hello").interceptIn(AuthInterceptor.class);')
out << contents
.replace('import com.netflix.karyon.servo.KaryonServoModule;', 'import com.netflix.karyon.servo.KaryonServoModule;\nimport com.netflix.karyon.eureka.KaryonEurekaModule;')
.replace('// KaryonEurekaModule.class,', 'KaryonEurekaModule.class, ')
// It's impossible to test REST calls from a browser if a HTTP Header is required.
.replace('interceptorSupport().forUri("/hello").interceptIn(AuthInterceptor.class);', '//interceptorSupport().forUri("/hello").interceptIn(AuthInterceptor.class);')
}

def scanning = new File(cloneRepo.gitDir, 'karyon-examples/hello-netflix-oss/src/main/resources/hello-netflix-oss.properties')
def scanning = new File(cloneRepo.gitDir, 'karyon-examples/src/main/resources/hello-netflix-oss.properties')
def scanContents = scanning.text
scanning.withWriter { out ->
// Let jersey scan Eureka package for healthcheck
out << scanContents.replace('com.netflix.hellonoss', 'com.netflix.hellonoss,com.netflix.appinfo')
// Let jersey scan Eureka package for healthcheck
out << scanContents.replace('com.netflix.karyon.examples.hellonoss', 'com.netflix.karyon.examples.hellonoss,com.netflix.appinfo')
}

def mc = new File(cloneRepo.gitDir, 'karyon-examples/build.gradle')
def mcContents = mc.text
mc.withWriter { out ->
// need to rewire
out << mcContents.replace("apply plugin: 'application'", "apply plugin: 'application'\nmainClassName = 'com.netflix.karyon.KaryonRunner'")
}
}
}

task patchEndpoint {
dependsOn 'cloneRepo'
dependsOn 'cloneRepo'
doFirst {
def app = new File(cloneRepo.gitDir, 'karyon-examples/hello-netflix-oss/src/main/java/com/netflix/hellonoss/server/HelloworldResource.java')
def app = new File(cloneRepo.gitDir, 'karyon-examples/src/main/java/com/netflix/karyon/examples/hellonoss/server/jersey/HelloworldResource.java')
def contents = app.text
app.withWriter { out ->
out << contents
.replace('Hello Netflix OSS component!', 'Hello Zero To Cloud developer!')
out << contents
.replace('Netflix OSS', 'Zero to Cloud Developers!')
}

}
Expand All @@ -42,20 +51,19 @@ task buildRepo(type: Build) {
dependsOn 'cloneRepo', 'patchRepo'
mustRunAfter 'patchEndpoint'
moduleDir = cloneRepo.gitDir
arguments = [':karyon-examples:hello-netflix-oss:distZip', '-x', 'check', '-x', 'signArchives', '-x', 'sourcesJar', '-x', 'javadocJar', '--stacktrace']
arguments = [':karyon-examples:distZip', '-x', 'check', '-x', 'signArchives', '-x', 'sourcesJar', '-x', 'javadocJar', '--stacktrace']
}

import org.apache.tools.ant.filters.*
ospackage {
def dist = new File(buildRepo.moduleDir, 'karyon-examples/hello-netflix-oss/build/distributions/hello-netflix-oss-2.1.00-RC3.zip')
def dist = new File(buildRepo.moduleDir, 'karyon-examples/build/distributions/karyon-examples-2.1.00-RC7.zip')
from( zipTree(dist) ) {
into('/opt')
}
from(file('root')) {
into('/')
filter ReplaceTokens, tokens: [ 'KARYON_OPTS': System.getenv('KARYON_OPTS') ?: '' ]
into('/opt')
}
postInstall('mv /opt/hello-netflix-oss* /opt/hello-netflix-oss') // zip was nested
postInstall('echo manual > /etc/init/tomcat7.override')
from(file('root')) {
into('/')
filter ReplaceTokens, tokens: [ 'KARYON_OPTS': System.getenv('KARYON_OPTS') ?: '' ]
}
postInstall('echo manual > /etc/init/tomcat7.override')
}
buildDeb.dependsOn(buildRepo)
buildDeb.dependsOn(buildRepo)
6 changes: 3 additions & 3 deletions karyon/root/etc/init/karyon.conf
Expand Up @@ -6,6 +6,6 @@ env enabled=1

respawn

env JAVA_OPTS="-Xmx2560m -Djava.awt.headless=true -Deureka.name=karyon -Deureka.region=us-west-2 -Deureka.port=8888 -Deureka.us-west-2.availabilityZones=default @KARYON_OPTS@"
exec start-stop-daemon --start --chuid ubuntu --chdir /opt/hello-netflix-oss/ \
--exec /opt/hello-netflix-oss/bin/hello-netflix-oss -- com.netflix.hellonoss.server.HelloWorldApp
env JAVA_OPTS="-Xmx2560m -Djava.awt.headless=true -Deureka.name=karyon -Deureka.region=us-west-2 -Deureka.port=80 -Deureka.us-west-2.availabilityZones=default @KARYON_OPTS@"
exec start-stop-daemon --start --chuid ubuntu --chdir /opt/karyon-examples-2.1.00-RC7/ \
--exec /opt/karyon-examples-2.1.00-RC7/bin/karyon-examples -- com.netflix.karyon.examples.hellonoss.server.jersey.JerseyHelloWorldApp