Newbie to Heroku here.
I've gone through the motions described here:
http://www.playframework.org/documentation/2.0.2/ScalaTodoList
And I've managed to set up a simple Play app on Heroku. Next up, I've tried uploading my main application which I've been developing on my own station, by going through the same steps as earlier. Uploading and compilation worked, however the app keeps crashing with code 255. Here is are the logs:
2012-08-21T19:07:29+00:00 heroku[slugc]: Slug compilation started
2012-08-21T19:10:18+00:00 heroku[api]: Attach HEROKU_POSTGRESQL_GOLD resource by heroku-postgresql#addons.heroku.com
2012-08-21T19:10:18+00:00 heroku[api]: Release v2 created by heroku-postgresql#addons.heroku.com
2012-08-21T19:10:18+00:00 heroku[api]: Add DATABASE_URL config by email#gmail.com
2012-08-21T19:10:18+00:00 heroku[api]: Release v3 created by email#gmail.com
2012-08-21T19:10:18+00:00 heroku[api]: Add SBT_OPTS, PATH, REPO, JAVA_OPTS config by b.panait#gmail.com
2012-08-21T19:10:18+00:00 heroku[api]: Release v4 created by email#gmail.com
2012-08-21T19:10:18+00:00 heroku[api]: Release v5 created by email#gmail.com
2012-08-21T19:10:18+00:00 heroku[api]: Deploy 40c5224 by email#gmail.com
2012-08-21T19:10:19+00:00 heroku[slugc]: Slug compilation finished
2012-08-21T19:10:25+00:00 heroku[web.1]: Starting process with command `target/start -Dhttp.port=28820 -Xmx384m -Xss512k
-XX:+UseCompressedOops`
2012-08-21T19:10:26+00:00 app[web.1]: This application is already running (Or delete the RUNNING_PID file).
2012-08-21T19:10:27+00:00 heroku[web.1]: Process exited with status 255
2012-08-21T19:10:27+00:00 heroku[web.1]: State changed from starting to crashed
2012-08-21T19:10:27+00:00 heroku[web.1]: State changed from crashed to starting
2012-08-21T19:10:30+00:00 heroku[web.1]: Starting process with command `target/start -Dhttp.port=21120 -Xmx384m -Xss512k
-XX:+UseCompressedOops`
2012-08-21T19:10:31+00:00 app[web.1]: This application is already running (Or delete the RUNNING_PID file).
2012-08-21T19:10:32+00:00 heroku[web.1]: Process exited with status 255
2012-08-21T19:10:32+00:00 heroku[web.1]: State changed from starting to crashed
2012-08-21T19:32:43+00:00 heroku[web.1]: State changed from crashed to starting
2012-08-21T19:32:47+00:00 heroku[web.1]: Starting process with command `target/start -Dhttp.port=35227 -Xmx384m -Xss512k
-XX:+UseCompressedOops`
2012-08-21T19:32:48+00:00 app[web.1]: This application is already running (Or delete the RUNNING_PID file).
2012-08-21T19:32:49+00:00 heroku[web.1]: Process exited with status 255
2012-08-21T19:32:49+00:00 heroku[web.1]: State changed from starting to crashed
2012-08-21T19:33:09+00:00 heroku[web.1]: State changed from crashed to starting
2012-08-21T19:33:13+00:00 heroku[web.1]: Starting process with command `target/start -Dhttp.port=3275 -Xmx384m -Xss512k
-XX:+UseCompressedOops`
2012-08-21T19:33:14+00:00 app[web.1]: This application is already running (Or delete the RUNNING_PID file).
2012-08-21T19:33:15+00:00 heroku[web.1]: Process exited with status 255
2012-08-21T19:33:16+00:00 heroku[web.1]: State changed from starting to crashed
I have no idea where to start investigating here. The main app is quite large, has some extra dependencies and uses a database. Any help is appreciated.
EDIT1: Ok, so I've deleted RUNNING_PID from my git repository (deleting it from heroku doesn't really work: https://devcenter.heroku.com/articles/ssh-access). I also updated my procfile to:
web: target/start -Dhttp.port=${PORT} ${JAVA_OPTS} -DapplyEvolutions.default=true -Ddb.default.url=${DATABASE_URL} -Ddb.default.driver=org.h2.Driver
I am now getting the following errors:
2012-08-21T20:24:45+00:00 heroku[slugc]: Slug compilation finished
2012-08-21T20:24:48+00:00 heroku[web.1]: Starting process with command `target/start -Dhttp.port=38558 -Xmx384m -Xss512k
-XX:+UseCompressedOops`
2012-08-21T20:24:51+00:00 app[web.1]: Play server process ID is 2
2012-08-21T20:24:57+00:00 app[web.1]: [←[37minfo←[0m] play - database [default] connected at jdbc:h2:mem:play
2012-08-21T20:24:58+00:00 app[web.1]: [←[33mwarn←[0m] play - Your production database [default] needs evolutions!
2012-08-21T20:24:58+00:00 app[web.1]:
2012-08-21T20:24:58+00:00 app[web.1]: # --- Rev:1,Ups - f9a96e0
...
Copy of the evolution file.
...
2012-08-21T20:24:58+00:00 app[web.1]:
2012-08-21T20:24:58+00:00 app[web.1]: [←[33mwarn←[0m] play - Run with -DapplyEvolutions.default=true if you want to run
them automatically (be careful)
2012-08-21T20:24:58+00:00 app[web.1]: Oops, cannot start the server.
2012-08-21T20:24:58+00:00 app[web.1]: PlayException: Database 'default' needs evolution! [An SQL script need to be run o
n your database.]
2012-08-21T20:24:58+00:00 app[web.1]: at play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$1.apply(Evolutions.s
cala:422)
2012-08-21T20:24:58+00:00 app[web.1]: at play.api.db.evolutions.EvolutionsPlugin$$anonfun$onStart$1.apply(Evolutions.s
cala:410)
2012-08-21T20:24:58+00:00 app[web.1]: at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59
)
2012-08-21T20:24:58+00:00 app[web.1]: at scala.collection.immutable.List.foreach(List.scala:45)
2012-08-21T20:24:58+00:00 app[web.1]: at play.api.db.evolutions.EvolutionsPlugin.onStart(Evolutions.scala:410)
2012-08-21T20:24:58+00:00 app[web.1]: at play.api.Play$$anonfun$start$1.apply(Play.scala:60)
2012-08-21T20:24:58+00:00 app[web.1]: at play.api.Play$$anonfun$start$1.apply(Play.scala:60)
2012-08-21T20:24:58+00:00 app[web.1]: at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59
)
2012-08-21T20:24:58+00:00 app[web.1]: at scala.collection.immutable.List.foreach(List.scala:45)
2012-08-21T20:24:58+00:00 app[web.1]: at play.api.Play$.start(Play.scala:60)
2012-08-21T20:24:58+00:00 app[web.1]: at play.core.StaticApplication.<init>(ApplicationProvider.scala:51)
2012-08-21T20:24:58+00:00 app[web.1]: at play.core.server.NettyServer$.createServer(NettyServer.scala:132)
2012-08-21T20:24:58+00:00 app[web.1]: at play.core.server.NettyServer$$anonfun$main$5.apply(NettyServer.scala:153)
2012-08-21T20:24:58+00:00 app[web.1]: at play.core.server.NettyServer$$anonfun$main$5.apply(NettyServer.scala:152)
2012-08-21T20:24:58+00:00 app[web.1]: at scala.Option.map(Option.scala:133)
2012-08-21T20:24:58+00:00 app[web.1]: at play.core.server.NettyServer$.main(NettyServer.scala:152)
2012-08-21T20:24:58+00:00 app[web.1]: at play.core.server.NettyServer.main(NettyServer.scala)
2012-08-21T20:25:00+00:00 heroku[web.1]: Process exited with status 255
2012-08-21T20:25:00+00:00 heroku[web.1]: State changed from starting to crashed
EDIT2:
Ok, I've figured out how to fix the problem with the evolutions. Simply add applyEvolutions.default=true to application.conf and the evolutions will be applied automatically. You have to be careful with this as it can destroy your data if you have destructors set up in your evolutions.
As Alper rightly suggested,
try adding -Dplay.evolutions.db.default.autoApplyDowns=true to your Procfile.
It fixed it for me.
Related
I'm trying to deploy a Scala Play project on Heroku via Heroku CLI.
It works well, but when the server tries to start it crashes with the following error:
2021-08-17T16:47:52.333689+00:00 app[web.1]: at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91)
2021-08-17T16:47:52.333713+00:00 app[web.1]: at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306)
2021-08-17T16:47:52.333753+00:00 app[web.1]: at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
2021-08-17T16:47:52.333762+00:00 app[web.1]: at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:168)
2021-08-17T16:47:52.333789+00:00 app[web.1]: at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:39)
2021-08-17T16:47:52.333813+00:00 app[web.1]: at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:62)
2021-08-17T16:47:52.333838+00:00 app[web.1]: at com.google.inject.internal.InternalInjectorCreator.loadEagerSingletons(InternalInjectorCreator.java:213)
2021-08-17T16:47:52.333867+00:00 app[web.1]: at com.google.inject.internal.InternalInjectorCreator.injectDynamically(InternalInjectorCreator.java:184)
2021-08-17T16:47:52.333893+00:00 app[web.1]: at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:111)
2021-08-17T16:47:52.333919+00:00 app[web.1]: at com.google.inject.Guice.createInjector(Guice.java:87)
2021-08-17T16:47:52.333942+00:00 app[web.1]: at com.google.inject.Guice.createInjector(Guice.java:78)
2021-08-17T16:47:52.333968+00:00 app[web.1]: at play.api.inject.guice.GuiceBuilder.injector(GuiceInjectorBuilder.scala:200)
2021-08-17T16:47:52.333993+00:00 app[web.1]: at play.api.inject.guice.GuiceApplicationBuilder.build(GuiceApplicationBuilder.scala:155)
2021-08-17T16:47:52.334018+00:00 app[web.1]: at play.api.inject.guice.GuiceApplicationLoader.load(GuiceApplicationLoader.scala:21)
2021-08-17T16:47:52.334042+00:00 app[web.1]: at play.core.server.ProdServerStart$.start(ProdServerStart.scala:53)
2021-08-17T16:47:52.334076+00:00 app[web.1]: at play.core.server.ProdServerStart$.main(ProdServerStart.scala:29)
2021-08-17T16:47:52.334102+00:00 app[web.1]: at play.core.server.ProdServerStart.main(ProdServerStart.scala)
2021-08-17T16:47:52.408221+00:00 heroku[web.1]: Process exited with status 255
2021-08-17T16:47:52.471552+00:00 heroku[web.1]: State changed from starting to crashed
2021-08-17T16:47:52.490499+00:00 heroku[web.1]: State changed from crashed to starting
2021-08-17T16:47:58.797308+00:00 heroku[web.1]: Starting process with command `target/universal/stage/bin/bionplaydatawarehouse -Dhttp.port=${PORT}`
2021-08-17T16:48:01.183756+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2021-08-17T16:48:01.398386+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -XX:+UseContainerSupport -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2021-08-17T16:48:06.203049+00:00 app[web.1]: WARNING: An illegal reflective access operation has occurred
2021-08-17T16:48:06.203069+00:00 app[web.1]: WARNING: Illegal reflective access by com.google.inject.internal.cglib.core.$ReflectUtils$1 (file:/app/target/universal/stage/lib/com.google.inject.guice-4.2.3.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
2021-08-17T16:48:06.203069+00:00 app[web.1]: WARNING: Please consider reporting this to the maintainers of com.google.inject.internal.cglib.core.$ReflectUtils$1
2021-08-17T16:48:06.203070+00:00 app[web.1]: WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
2021-08-17T16:48:06.203076+00:00 app[web.1]: WARNING: All illegal access operations will be denied in a future release
2021-08-17T16:48:15.071607+00:00 app[web.1]: Oops, cannot start the server.
The projet parameters are:
Play 2.8.8
Scala 2.13.5
SBT 1.5.0
Java 11
The project is based on an IntelliJ Ultimate Template.
The Heroku Procfile looks like this:
web: target/universal/stage/bin/bionplaydatawarehouse -Dhttp.port=${PORT}
The system.properties file looks like this to overwrite the default Java 8 Version:
java.runtime.version=11
When I change the Java Version the compilation crashes with a Class Cast Exception.
It seems that the Guice DI is the problem or some configuration parameter is missing for the Heroku production invironment because locally the projects works well.
I got it!
You need to add the -Dplay.http.secret.key argument which value must match your appliaction secret.
Unfortunately this was not part auf the documetation
web: target/universal/stage/bin/myProject -Dhttp.port=${PORT}
-Dplay.http.secret.key='mySecret'
I wrote a 20-minute web-service that I needed quickly deployed, so I thought of Heroku. I went through their example, added a Procfile as per the documentation:
web: java $JVM_OPTS -cp target/random-pairs.jar Clojure.main -m random-pairs.system
The server is just jetty wrapped in a Component/Lifecycle interface implementation, so I added calls that read PORT/HOST from Heroku ENV, also didn't take long:
(defn new []
(let [host (or (System/getenv "HOST") "localhost")
port (or (Integer. (System/getenv "PORT")) 8080)]
(map->Server {:host host :port port :server nil :database nil})))
Then I pushed to heroku branch and was very happy to see that it builds:
remote: -----> Clojure (Leiningen 2) app detected
remote: -----> Installing OpenJDK 1.8... done
remote: -----> Using cached Leiningen 2.7.1
remote: Writing: lein script
remote: -----> Building with Leiningen
remote: Running: lein uberjar
remote: Compiling random-pairs.api
remote: Compiling random-pairs.routing
remote: Compiling random-pairs.server
remote: Compiling random-pairs.system
remote: Compiling random-pairs.utils
remote: Created /tmp/build_39db3b5354727cb980092a4caa080664/target/random-pairs-0.1.0-SNAPSHOT.jar
remote: Created /tmp/build_39db3b5354727cb980092a4caa080664/target/random-pairs.jar
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 70.5M
remote: -----> Launching...
I peeked at the logs to confirm:
2017-09-27T10:11:43.214499+00:00 heroku[web.1]: Starting process with command `java $JVM_OPTS -cp target/random-pairs.jar clojure.main -m random-pairs.system`
2017-09-27T10:11:46.312843+00:00 app[web.1]: Setting JAVA_TOOL_OPTIONS defaults based on dyno size. Custom settings will override them.
2017-09-27T10:11:46.316262+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -Dfile.encoding=UTF-8
2017-09-27T10:11:49.562990+00:00 app[web.1]: 2017-09-27 10:11:49.559 INFO default org.eclipse.jetty.util.log - Logging initialized #3234ms
2017-09-27T10:11:50.401779+00:00 app[web.1]: 2017-09-27 10:11:50.401 INFO default random-pairs.system - :random-pairs.system/create-system Creating system
2017-09-27T10:11:50.404459+00:00 app[web.1]: 2017-09-27 10:11:50.404 INFO default random-pairs.system - :random-pairs.system/start Starting the application
2017-09-27T10:11:50.409370+00:00 app[web.1]: 2017-09-27 10:11:50.409 INFO default random-pairs.server - :random-pairs.server/server-start Starting Server component host: localhost port: 15701
2017-09-27T10:11:50.435805+00:00 app[web.1]: 2017-09-27 10:11:50.435 INFO default org.eclipse.jetty.server.Server - jetty-9.2.z-SNAPSHOT
2017-09-27T10:11:50.478304+00:00 app[web.1]: 2017-09-27 10:11:50.477 INFO default o.e.jetty.server.ServerConnector - Started ServerConnector#1a1f79ce{HTTP/1.1}{localhost:15701}
2017-09-27T10:11:50.478742+00:00 app[web.1]: 2017-09-27 10:11:50.478 INFO default org.eclipse.jetty.server.Server - Started #4162ms
2017-09-27T10:11:50.479247+00:00 app[web.1]: 2017-09-27 10:11:50.479 INFO default random-pairs.system - :random-pairs.system/main Application fully functional
Nice, Heroku seems neat.
So I went on to send some requests to test everything works OK. Only that it didn't. I looked once again at the logs only to see:
2017-09-27T10:13:48.345516+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2017-09-27T10:13:48.345575+00:00 heroku[web.1]: Stopping process with SIGKILL
2017-09-27T10:13:48.488069+00:00 heroku[web.1]: State changed from starting to crashed
2017-09-27T10:13:48.476415+00:00 heroku[web.1]: Process exited with status 137
What is this in the name of Zeus? Failed to bind to $PORT? I clearly see in the logs Jetty picked up the port and the system went online?
I know what happens - it's classic IP4/IP6, "localhost" resolves to ip6 address on heroku cloud machine. Putting 0.0.0.0 (or presumably also specifying no host as suggested in the comment) solves the problem.
Could anyone please help with Heroku's guide of "getting started with java":
https://devcenter.heroku.com/articles/getting-started-with-java
It works fine with scale=1
But it fails when I try to scale up, eg:
heroku ps:scale web=2 --app myap
This responds "internal server error" and asks to run "heroku status".
However "heroku status" just says "no knows issues at this time".
And "heroku:logs" doesn't give much info, except perhaps some "413" error:
2013-12-19T06:42:53+00:00 heroku[slug-compiler]: Slug compilation finished
2013-12-19T06:42:53.947859+00:00 heroku[web.1]: State changed from up to starting
2013-12-19T06:42:57.590970+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2013-12-19T06:42:58.225911+00:00 heroku[web.1]: Starting process with command `java -cp target/classes:target/dependency/* HelloWorld`
2013-12-19T06:42:59.363034+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Djava.rmi.server.useCodebaseOnly=true -Djava.rmi.server.useCodebaseOnly=true
2013-12-19T06:42:59.677493+00:00 app[web.1]: 2013-12-19 06:42:59.675:INFO:oejs.Server:jetty-7.6.0.v20120127
2013-12-19T06:42:59.752285+00:00 app[web.1]: 2013-12-19 06:42:59.751:INFO:oejsh.
ContextHandler:started o.e.j.s.ServletContextHandler{/,null}
2013-12-19T06:42:59.795692+00:00 app[web.1]: 2013-12-19 06:42:59.787:INFO:oejs.A
bstractConnector:Started SelectChannelConnector#0.0.0.0:37683
2013-12-19T06:42:59.936719+00:00 heroku[web.1]: Process exited with status 143
2013-12-19T06:43:00.226719+00:00 heroku[web.1]: State changed from starting to u
Help would be appreciated,
thanks very much
After updating to Meteor 0.6.5 this https://github.com/jordansissel/heroku-buildpack-meteor doesn’t work any more. Logs from Heroku app:
2013-08-15T12:06:29+00:00 heroku[slug-compiler]: Slug compilation started
2013-08-15T12:06:43.647196+00:00 heroku[api]: Deploy 213bfc9 by artpolikarpov#getwear.com
2013-08-15T12:06:43.671450+00:00 heroku[api]: Release v350 created by artpolikarpov#getwear.com
2013-08-15T12:06:43.777150+00:00 heroku[web.1]: State changed from down to starting
2013-08-15T12:06:44+00:00 heroku[slug-compiler]: Slug compilation finished
2013-08-15T12:06:46.259053+00:00 heroku[web.1]: Starting process with command `PATH=.meteor/local/usr/bin:.meteor/local/usr/lib/meteor/bin:bin:/usr/local/bin:/usr/bin:/bin NODE_PATH=.meteor/local/usr/lib/meteor/lib/node_modules MONGO_URL=mongodb://heroku:c2130dda19da2b5a60ffae67ce4134a5#dharma.mongohq.com:10026/app14902610 .meteor/local/usr/lib/meteor/bin/node .meteor/local/build/main.js`
2013-08-15T12:06:46.926998+00:00 app[web.1]: module.js:340
2013-08-15T12:06:46.930406+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:338:15)
2013-08-15T12:06:46.926865+00:00 app[web.1]:
2013-08-15T12:06:46.927270+00:00 app[web.1]: throw err;
2013-08-15T12:06:46.927270+00:00 app[web.1]: ^
2013-08-15T12:06:46.930406+00:00 app[web.1]: Error: Cannot find module '/app/.meteor/local/build/main.js'
2013-08-15T12:06:46.930406+00:00 app[web.1]: at Function.Module._load (module.js:280:25)
2013-08-15T12:06:46.930406+00:00 app[web.1]: at process.startup.processNextTick.process._tickCallback (node.js:244:9)
2013-08-15T12:06:46.930406+00:00 app[web.1]: at Module.runMain (module.js:492:10)
2013-08-15T12:06:48.127332+00:00 heroku[web.1]: Process exited with status 1
Can any one help?
Ok. Moving to another buildpack helped me. Now I’m using: https://github.com/oortcloud/heroku-buildpack-meteorite.
To move too, set new URL to the BUILDPACK_URL variable:
heroku config:set BUILDPACK_URL=https://github.com/oortcloud/heroku-buildpack-meteorite.git
To avoid the Meteor requires Node v0.8.24 or later error, define package.json in the root of your meteor project with the something like:
{
"name": "Whatever",
"version": "0.0.1",
"engines": {
"node": "0.8.24"
}
}
When deploying to heroku I get the following error log:
2013-08-05T18:14:39.217252+00:00 heroku[web.1]: State changed from crashed to starting
2013-08-05T18:14:43.819448+00:00 heroku[web.1]: Starting process with command `node server.js`
2013-08-05T18:14:45.272628+00:00 app[web.1]:
2013-08-05T18:14:45.274663+00:00 app[web.1]: module.js:340
2013-08-05T18:14:45.277076+00:00 app[web.1]: throw err;
2013-08-05T18:14:45.277256+00:00 app[web.1]: ^
2013-08-05T18:14:45.279157+00:00 app[web.1]: Error: Cannot find module '/app/server.js'
2013-08-05T18:14:45.279157+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:338:15)
2013-08-05T18:14:45.279157+00:00 app[web.1]: at Function.Module._load (module.js:280:25)
2013-08-05T18:14:45.279157+00:00 app[web.1]: at Function.Module.runMain (module.js:497:10)
2013-08-05T18:14:45.279157+00:00 app[web.1]: at startup (node.js:119:16)
2013-08-05T18:14:45.279157+00:00 app[web.1]: at node.js:901:3
2013-08-05T18:14:46.719239+00:00 heroku[web.1]: Process exited with status 8
2013-08-05T18:14:46.736590+00:00 heroku[web.1]: State changed from starting to crashed
I'm new to derbyjs as well as heroku ... great, great, great tools, anyway!
So, why is the app complaining about a /app/server.js file?
It's a coffeescript project, and as far as I am aware, it uses browserify to deliver js on the fly. Also, there simply is no server.coffee in the app dir ... as it is the app dir, how can there ever be a server.js in it?? well, surely some meaning hidden from me for now.
Guys, can you help out?
I'm using:
Derby 0.5.9
Heroku Toolbelt ... just installed before writing this task
Deploy steps as explained on derbyjs.com
Cheers, Joehannes