2017-05-08 4 views
0

Ich habe einen kleinen Demo-Server auf meinem Computer mit Java Sun httpserver Bibliothek gebaut.Heroku Java Webserver-Bereitstellung mit Sonne httpserver

Jetzt möchte ich an die Öffentlichkeit gehen und es auf Heroku bereitstellen.

einfach gesagt, das ist meine Main.java Klasse (unten).

Es wird als Maven-Projekt gebaut.

Ich habe Herkou mit meinem Maven-Projekt verbunden (Code sitzt auf Github) und die Compile- und Run-Phase mit Maven gibt mir "Build-Erfolg".

Aber, wenn ich versuche, meine Server zuzugreifen, wie ich in meinem lokalen enviromnet tat (http://localhost:8000/test), wenn ich diese URL (meine herkou Website) eingeben: https://shaffa.herokuapp.com:8000/test ich jetzt eine Nachricht bin immer sagen: „Seite kann nicht geladen werden ".

Hat herkou automaticlly meine Hauptmethode in Maven-Projekt laufen (Ich brauche es der Fall zu sein, da mein Server an meiner Haupt-Methode beginnt) ..

wenn es der Fall ist, was denn sonst könnte das Problem sein?

Danke!

public class Main { 
    static MySQLQueryExecutor mySQLQueryExecutor=MySQLQueryExecutor.getInstance(); 
    public static void main(String[] args) throws Exception { 
     HttpServer server = HttpServer.create(new InetSocketAddress(8000), 0); 
     server.createContext("/test", new MyHandler()); 

     server.setExecutor(null); 
     server.start(); 
     System.out.println(server.getAddress()); 
    } 



    static class MyHandler implements HttpHandler { 

     public void handle(HttpExchange t) throws IOException { 
      String response = "This is Get response"; 
      t.sendResponseHeaders(200, response.length()); 
      OutputStream os = t.getResponseBody(); 
      os.write(response.getBytes()); 
      os.close(); 
     } 
    } 


} 

Gebäude log:

-----> Java app detected 
-----> Installing OpenJDK 1.8... done 
-----> Installing Maven 3.3.9... done 
-----> Executing: mvn -DskipTests clean dependency:list install 
     [INFO] Scanning for projects... 
     [INFO]                   
     [INFO] ------------------------------------------------------------------------ 
     [INFO] Building my_demo 1.0-SNAPSHOT 
     [INFO] ------------------------------------------------------------------------ 
     [INFO] 
     [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ my_demo --- 
     [INFO] 
     [INFO] --- maven-dependency-plugin:2.8:list (default-cli) @ my_demo --- 
     [INFO] 
     [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ my_demo --- 
     [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! 
     [INFO] skip non existing resourceDirectory /tmp/build_0073fd7c9decf8f53d270853eac0864e/Matoy7-ShaffaServer-dd12826/src/main/resources 
     [INFO] 
     [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ my_demo --- 
     [INFO] No sources to compile 
     [INFO] 
     [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ my_demo --- 
     [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent! 
     [INFO] skip non existing resourceDirectory /tmp/build_0073fd7c9decf8f53d270853eac0864e/Matoy7-ShaffaServer-dd12826/src/test/resources 
     [INFO] 
     [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ my_demo --- 
     [INFO] No sources to compile 
     [INFO] 
     [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ my_demo --- 
     [INFO] Tests are skipped. 
     [INFO] 
     [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ my_demo --- 
     [WARNING] JAR will be empty - no content was marked for inclusion! 
     [INFO] Building jar: /tmp/build_0073fd7c9decf8f53d270853eac0864e/Matoy7-ShaffaServer-dd12826/target/my_demo-1.0-SNAPSHOT.jar 
     [INFO] 
     [INFO] --- maven-install-plugin:2.4:install (default-install) @ my_demo --- 
     [INFO] Installing /tmp/build_0073fd7c9decf8f53d270853eac0864e/Matoy7-ShaffaServer-dd12826/target/my_demo-1.0-SNAPSHOT.jar to /app/tmp/cache/.m2/repository/yotam/my_demo/1.0-SNAPSHOT/my_demo-1.0-SNAPSHOT.jar 
     [INFO] Installing /tmp/build_0073fd7c9decf8f53d270853eac0864e/Matoy7-ShaffaServer-dd12826/pom.xml to /app/tmp/cache/.m2/repository/yotam/my_demo/1.0-SNAPSHOT/my_demo-1.0-SNAPSHOT.pom 
     [INFO] ------------------------------------------------------------------------ 
     [INFO] BUILD SUCCESS 
     [INFO] ------------------------------------------------------------------------ 
     [INFO] Total time: 2.365 s 
     [INFO] Finished at: 2017-05-08T16:28:54+00:00 
     [INFO] Final Memory: 16M/167M 
     [INFO] ------------------------------------------------------------------------ 
-----> Discovering process types 
     Procfile declares types -> (none) 
-----> Compressing... 
     Done: 48M 
-----> Launching... 
     Released v7 
     https://shaffa.herokuapp.com/ deployed to Heroku 

Anwendungsprotokolle

2017-05-08T14:17:52.452910+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=shaffa.herokuapp.com request_id=5f365605-2f15-45d7-a043-5aea122ab4b8 fwd="109.64.111.39" dyno= connect= service= status=503 bytes= protocol=https 
2017-05-08T16:28:47.000000+00:00 app[api]: Build started by user [email protected] 
2017-05-08T16:28:49.000000+00:00 app[api]: Build started by user [email protected] 
2017-05-08T16:29:00.835249+00:00 app[api]: Deploy dd12826 by user [email protected] 
2017-05-08T16:29:00.835249+00:00 app[api]: Release v7 created by user [email protected] 
2017-05-08T16:28:47.000000+00:00 app[api]: Build succeeded 
2017-05-08T16:29:03.635910+00:00 app[api]: Deploy dd12826 by user [email protected] 
2017-05-08T16:28:49.000000+00:00 app[api]: Build succeeded 
2017-05-08T16:29:03.635910+00:00 app[api]: Release v8 created by user [email protected] 
2017-05-08T16:29:08.055046+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=shaffa.herokuapp.com request_id=c06affca-0979-4e7c-aafe-69e5296a33c0 fwd="109.64.111.39" dyno= connect= service= status=503 bytes= protocol=https 
2017-05-08T16:29:08.706745+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=shaffa.herokuapp.com request_id=f11fe11a-a99a-4f19-bbff-34b0a84fa1f3 fwd="109.64.111.39" dyno= connect= service= status=503 bytes= protocol=https 
+0

Führen Sie nach der Bereitstellung 'heroku logs -t' aus, und buchen Sie die Ausgabe hier. – codefinger

+0

Was beinhaltet Ihre Procfile? – codefinger

+0

hinzugefügt in Original-Nachricht – Matoy

Antwort

0

Sie benötigen App skaliert bis zu mindestens einem dyno in der Registerkarte Ressourcen des Armaturenbretts.

Verwandte Themen