-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add a warding processor #3
base: master
Are you sure you want to change the base?
Changes from all commits
7e49bb5
2dab48f
c7be138
74474b1
a72fcaa
47530fb
510d6f2
063e10c
39c1428
cb76494
966684a
4141fad
55a0a45
57fa27b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ notifications: | |
- [email protected] | ||
- [email protected] | ||
script: | ||
- docker build -t yasp/parser . | ||
- docker build -t odota/parser . | ||
deploy: | ||
provider: script | ||
skip_cleanup: true | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,6 @@ WORKDIR /usr/src/parser | |
ADD . /usr/src/parser | ||
RUN mvn -q -f /usr/src/parser/pom.xml clean install -U | ||
|
||
EXPOSE 5600 | ||
|
||
CMD ["java", "-jar", "-Xmx256m", "/usr/src/parser/target/stats-0.1.0.jar", "5600"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. will you need to update this for the jar name? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I've changed the pom.xml to output the same filename as before. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,27 +40,27 @@ | |
</repository> | ||
</repositories> | ||
<dependencies> | ||
<!-- | ||
<dependency> | ||
<groupId>com.github.skadistats</groupId> | ||
<artifactId>clarity</artifactId> | ||
<version>master-SNAPSHOT</version> | ||
</dependency> | ||
--> | ||
<!-- | ||
<dependency> | ||
<groupId>com.github.skadistats</groupId> | ||
<artifactId>clarity</artifactId> | ||
<version>70956f5a89fca56f3a292e739ea3eda96a33fd8c</version> | ||
</dependency> | ||
--> | ||
<!-- | ||
<dependency> | ||
<groupId>com.github.skadistats</groupId> | ||
<artifactId>clarity</artifactId> | ||
<version>master-SNAPSHOT</version> | ||
</dependency> | ||
--> | ||
<!-- | ||
<dependency> | ||
<groupId>com.github.skadistats</groupId> | ||
<artifactId>clarity</artifactId> | ||
<version>70956f5a89fca56f3a292e739ea3eda96a33fd8c</version> | ||
</dependency> | ||
--> | ||
|
||
<dependency> | ||
<groupId>com.skadistats</groupId> | ||
<artifactId>clarity</artifactId> | ||
<version>2.1</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.google.code.gson</groupId> | ||
<artifactId>gson</artifactId> | ||
|
@@ -71,24 +71,56 @@ | |
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>2.2</version> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>3.0.2</version> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<addClasspath>true</addClasspath> | ||
<mainClass>yasp.Main</mainClass> | ||
</manifest> | ||
</archive> | ||
<finalName>${project.build.finalName}-original</finalName> | ||
</configuration> | ||
</plugin> | ||
<!-- this is used by clarity-example and clarity-analyzer --> | ||
<plugin> | ||
<groupId>com.jolira</groupId> | ||
<artifactId>onejar-maven-plugin</artifactId> | ||
<version>1.4.4</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
<goal>one-jar</goal> | ||
</goals> | ||
<configuration> | ||
<transformers> | ||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
<mainClass>yasp.Main</mainClass> | ||
</transformer> | ||
</transformers> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<filename>${project.build.finalName}.jar</filename> | ||
</configuration> | ||
</plugin> | ||
<!-- for some reason the shade-plugin doesn't work well with clarity processors. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. preferably we should find a way to avoid needing to swap this dependency. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I took like 3 hours today trying to make this work. Maybe @spheenik can give some guidance because the shaded jar will crash upon populating the processors. It seems it cannot find the annotations or whatever. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC this produces a jar with a different name. We have to make sure the output file is named the same, or update the Dockerfile to start the correct file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem here is that there is an annotation scanner in clarity ( |
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-shade-plugin</artifactId> | ||
<version>2.2</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>shade</goal> | ||
</goals> | ||
<configuration> | ||
<transformers> | ||
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | ||
<mainClass>yasp.Main</mainClass> | ||
</transformer> | ||
</transformers> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
--> | ||
</plugins> | ||
</build> | ||
</project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/bin/bash | ||
|
||
sudo docker build -t odota/parser . | ||
sudo docker rm -fv parser | ||
sudo docker build -t yasp/parser . | ||
sudo docker run -d --name parser --net=host yasp/parser | ||
sudo docker run -d --name parser --net=host odota/parser |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,35 +2,55 @@ | |
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.FileInputStream; | ||
import java.io.OutputStream; | ||
import java.net.InetSocketAddress; | ||
import com.sun.net.httpserver.HttpExchange; | ||
import com.sun.net.httpserver.HttpHandler; | ||
import com.sun.net.httpserver.HttpServer; | ||
|
||
public class Main { | ||
|
||
public static void main(String[] args) throws Exception { | ||
HttpServer server = HttpServer.create(new InetSocketAddress(Integer.valueOf(args.length > 0 ? args[0] : "5600")), 0); | ||
server.createContext("/", new MyHandler()); | ||
server.setExecutor(java.util.concurrent.Executors.newFixedThreadPool(4)); | ||
server.start(); | ||
if (args.length > 0 && args[0].equals("--file")) { System.exit(parseFile(args[1])); } | ||
else if (args.length > 0 && args[0].equals("--")) { System.exit(parseStream(System.in, System.out)); } | ||
else { startServer(args); } | ||
} | ||
|
||
public static void startServer(String[] args) throws Exception { | ||
HttpServer server = HttpServer.create(new InetSocketAddress(Integer.valueOf(args.length > 0 ? args[0] : "5600")), 0); | ||
server.createContext("/", new MyHandler()); | ||
server.setExecutor(java.util.concurrent.Executors.newFixedThreadPool(4)); | ||
server.start(); | ||
} | ||
|
||
private static int parseStream(InputStream is, OutputStream os) throws IOException { | ||
try { | ||
new Parse(is, os); | ||
} | ||
catch (Exception e) | ||
{ | ||
e.printStackTrace(); | ||
return -1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extra space |
||
} | ||
finally { | ||
is.close(); | ||
os.close(); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
private static int parseFile(String replayFile) throws Exception { | ||
System.out.print(String.format("Parsing file %s", replayFile)); | ||
return parseStream(new FileInputStream(replayFile), System.out); | ||
} | ||
|
||
static class MyHandler implements HttpHandler { | ||
@Override | ||
public void handle(HttpExchange t) throws IOException { | ||
t.sendResponseHeaders(200, 0); | ||
InputStream is = t.getRequestBody(); | ||
OutputStream os = t.getResponseBody(); | ||
try { | ||
new Parse(is, os); | ||
} | ||
catch (Exception e) | ||
{ | ||
e.printStackTrace(); | ||
} | ||
os.close(); | ||
} | ||
@Override | ||
public void handle(HttpExchange t) throws IOException { | ||
t.sendResponseHeaders(200, 0); | ||
parseStream(t.getRequestBody(), t.getResponseBody()); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how did this work before? port option passed via Docker command line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is because the new docker-compose is using named services to access the other services instead of going through the host networking. It is good practice to EXPOSE listening ports on your docker components, it makes it easy to expose the service to other components.
As you can see in
docker-compose.yml
I think docker-compose automatically expose the image EXPOSED ports.