Skip to content

Commit

Permalink
update main.java
Browse files Browse the repository at this point in the history
  • Loading branch information
derekoneil committed Dec 1, 2017
1 parent bfe8317 commit ea678ee
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build/
target/
.metadata
.wercker/
31 changes: 19 additions & 12 deletions src/main/java/com/example/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,20 @@ public static HttpServer startServer() throws UnknownHostException {
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
public static void main(String[] args) throws IOException, InterruptedException {
final HttpServer server = startServer();

server.getServerConfiguration().addHttpHandler(new HttpHandler() {
// final SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
//
//
// @Override
// public void service(Request request, Response response) throws Exception {
// final Date now = new Date();
// final String formattedTime;
// synchronized (formatter) {
// formattedTime = formatter.format(now);
// }
//
//
// response.setContentType("text/plain");
// response.getWriter().write("The time using the old Java Date object is: " + formattedTime);
// }
Expand All @@ -73,9 +73,9 @@ public void service(Request request, Response response) throws Exception {
response.getWriter().write("The time using the new java.time API in Java 8 is: " + LocalTime.now().truncatedTo(ChronoUnit.SECONDS));
}
}, "/time");



// Add the StaticHttpHandler to serve static resources from the static folder
// server.getServerConfiguration().addHttpHandler(
// new StaticHttpHandler("src/main/resources/static/"), "static/");
Expand All @@ -93,10 +93,17 @@ public void service(Request request, Response response) throws Exception {
System.out.println(String.format("%sstatictweets</search> to see a set of stored static tweets", BASE_URI));
System.out.println(String.format("%sjarstatic/index.html to see the jar static resource", BASE_URI));
System.out.println();
System.out.println("Press enter to stop the server...");

System.in.read();
server.shutdown();
System.out.println("Press enter to NOT stop the server...");

try {
System.out.println("Joining current thread...");
Thread.currentThread().join();
System.out.println("Joined current thread.");
}
catch (Exception e) {
System.out.println("Caught Exception: " + e);
}
// System.in.read();
// server.shutdown();
}
}

16 changes: 11 additions & 5 deletions wercker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Docker Hub https://registry.hub.docker.com/_/debian/
# Read more about containers on our dev center
# http://devcenter.wercker.com/docs/containers/index.html
box:
box:
id: openjdk
ports:
- "8080"
Expand All @@ -29,10 +29,16 @@ build:
name: maven build
code: |
./build.sh
dev:
steps:
- script:
name: start dev
code: |
pwd; ls; sh target/bin/start
publish:
steps:
- internal/docker-push:
repository: wcr.io/derekoneil/twitter-feed
repository: wcr.io/derekoneil/twitter-feed
cmd: pipeline/source/target/bin/start

push-release:
Expand All @@ -42,21 +48,21 @@ push-release:
working-dir: /pipeline/source
ports: "8080"
cmd: ./target/bin/start

#delete any existing Wercker secret before creating, to accommodate secret changes
inject-secret:
box:
id: alpine
cmd: /bin/sh
steps:

- kubectl:
name: delete secret
server: $KUBERNETES_MASTER
token: $KUBERNETES_TOKEN
insecure-skip-tls-verify: true
command: delete secret wercker; echo delete registry secret

- kubectl:
name: create secret
server: $KUBERNETES_MASTER
Expand Down

0 comments on commit ea678ee

Please sign in to comment.