base grails 3.3.8 app demolishes heroku memory limit - heroku

I am trying to write a simple grails 3.3.8 app that I would like to deploy to heroku.
I started with a simple grails app:
$ grails create-app example
I then added a Procfile:
web: ./gradlew bootRun -Dgrails.server.port=$PORT
And a stage task to build.gradle:
task stage(dependsOn: assemble)
I figure that this app does nothing, and therefore should not stress a 512M heroku dyno, however:
2018-11-05T02:43:28.390592+00:00 app[web.1]: Picked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2018-11-05T02:43:32.587318+00:00 heroku[web.1]: Process running mem=729M(142.5%)
2018-11-05T02:43:32.587564+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2018-11-05T02:43:36.536505+00:00 app[web.1]: :buildProperties
2018-11-05T02:43:37.378484+00:00 app[web.1]: :processResources
2018-11-05T02:43:37.381277+00:00 app[web.1]: :classes
2018-11-05T02:43:37.403505+00:00 app[web.1]: :findMainClass
2018-11-05T02:43:37.519404+00:00 app[web.1]: :bootRunPicked up JAVA_TOOL_OPTIONS: -Xmx300m -Xss512k -XX:CICompilerCount=2 -Dfile.encoding=UTF-8
2018-11-05T02:43:54.618402+00:00 heroku[web.1]: Process running mem=1164M(227.5%)
2018-11-05T02:43:54.618533+00:00 heroku[web.1]: Error R15 (Memory quota vastly exceeded)
2018-11-05T02:43:54.618676+00:00 heroku[web.1]: Stopping process with SIGKILL
2018-11-05T02:43:54.788397+00:00 heroku[web.1]: Process exited with status 137
2018-11-05T02:43:54.804734+00:00 heroku[web.1]: State changed from starting to crashed

bootRun is for running and developing locally. Its optimized for quick development, not for running in production.
To run in production you would normally run
./gradlew assemble
# Deploy build/libs/app.jar(or war) to your server
java -jar app.jar
There are many more ways to run a spring-boot/grails apps, for example deploying to tomcat or other servlet containers.

Related

Why does the FastAPI startup event run twice in HEROKU?

When I deployed a FastAPI app to heroku
the startup event is fired twice.
Is it my problem?
The code below is not my original app, but a temporary app I made for testing.
And the Heroku was also made fresh for testing.
# Heroku logs
2022-10-18T08:37:32 app[api]: Build started by user junah.dev+1#gmail.com
2022-10-18T08:37:49 app[api]: Deploy 298098b0 by user junah.dev+1#gmail.com
2022-10-18T08:37:49 app[api]: Release v6 created by user junah.dev+1#gmail.com
2022-10-18T08:37:52 heroku[web.1]: State changed from down to starting
2022-10-18T08:37:54 heroku[web.1]: Starting process with command `uvicorn app.main:app --host=0.0.0.0 --port=${PORT:-5000}`
2022-10-18T08:37:55 app[api]: Build succeeded
2022-10-18T08:37:55.490285+00:00 app[web.1]: INFO: Uvicorn running on http://0.0.0.0:51121 (Press CTRL+C to quit)
2022-10-18T08:37:55 app[web.1]: INFO: Started parent process [4]
2022-10-18T08:37:55 app[web.1]: INFO: Started server process [11]
2022-10-18T08:37:55 app[web.1]: INFO: Waiting for application startup.
2022-10-18T08:37:55 app[web.1]: INFO: Application startup complete.
2022-10-18T08:37:55 app[web.1]: INFO: Started server process [10]
2022-10-18T08:37:55 app[web.1]: INFO: Waiting for application startup.
2022-10-18T08:37:55 app[web.1]: INFO: Application startup complete.
2022-10-18T08:37:56 heroku[web.1]: State changed from starting to up
# main.py
from fastapi import Depends, FastAPI
import uvicorn
app = FastAPI()
#app.get("/")
async def root():
return {"message": "Hello World"}
# Procfile
web: uvicorn app.main:app --host=0.0.0.0 --port=${PORT:-5000}
Uvicorn operates by running worker processes.
If you don't give it a number of processes to use via the --workers argument, it defaults to the value of the WEB_CONCURRENCY environment variable, falling back to 1 if neither is set:
--workers INTEGER Number of worker processes. Defaults to the
$WEB_CONCURRENCY environment variable if
available, or 1. Not valid with --reload.
Heroku sets a default value for the WEB_CONCURRENCY environment variable:
The WEB_CONCURRENCY environment variable is automatically set by Heroku, based on the processes’ Dyno size. This feature is intended to be a sane starting point for your application. We recommend knowing the memory requirements of your processes and setting this configuration variable accordingly.
Heroku has probably set this value to 2 based on the size of the dynos you are running. This would cause two workers to run in parallel, which is what your logs are showing:
A parent process: Started parent process [4]
And two worker processes:
Started server process [11]
Started server process [10]
You can change the value of WEB_CONCURRENCY if you wish.
If your code is malfunctioning with multiple workers that indicates a problem with your code. In that case, instead of setting this to 1, I suggest you identify why it is misbehaving and fix the problem. One common cause of this is use of global variables.

How to run a node app with no listening port in Heroku

I have a node app that does a simple web scraping in real time.
Since it has no back-end feature, it doesn't listen any port and never use Express.
When I deploy this app, Heroku automatically runs some commands to build and run my app.
This is my package.json file.
"scripts": {
"develop": "nodemon --exec babel-node src",
"test": "mocha --require babel-core/register",
"build": "rimraf lib && babel src -d lib",
"start": "node lib",
"lint": "eslint src"
}
I checked the Heroku logs to see if the app is running properly but I found errors like below.
...
2020-12-27T07:24:48.000000+00:00 app[api]: Build succeeded
2020-12-27T07:25:46.564866+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-12-27T07:25:46.589773+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-12-27T07:25:46.680704+00:00 heroku[web.1]: Process exited with status 137
2020-12-27T07:25:46.732427+00:00 heroku[web.1]: State changed from starting to crashed
2020-12-27T07:25:46.735872+00:00 heroku[web.1]: State changed from crashed to starting
2020-12-27T07:25:51.844095+00:00 heroku[web.1]: Starting process with command `npm start`
2020-12-27T07:25:54.728760+00:00 app[web.1]:
2020-12-27T07:25:54.728776+00:00 app[web.1]: > my-node-app#0.1.0 start /app
2020-12-27T07:25:54.728777+00:00 app[web.1]: > node lib
2020-12-27T07:25:54.728777+00:00 app[web.1]:
2020-12-27T07:26:52.296540+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-12-27T07:26:52.315003+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-12-27T07:26:52.410290+00:00 heroku[web.1]: Process exited with status 137
2020-12-27T07:26:52.468187+00:00 heroku[web.1]: State changed from starting to crashed
It seems building was successful but has failed when running it.
In my opinion, Heroku tried to bind PORT but my app never listened any port, so these errors had occurred.
How can I run my app successfully with no error on Heroku in this case?
If your node.js project is a web server, you cannot remove the port. No port, no web server. Trying to make a web server without a port is like trying to make a locomotive with no railroad.
You can use the default port however. When users give browsers URLs without ports, they automatically apply the default port.
Heroku also provide the default port so you don't have to specify the port
Just deploy your app and use the url provided by the heroku to call node js application

Nuxt App deployed to Heroku doesn't find sass-loader

I'm trying to deploy a Nuxt SPA app to Heroku.
Locally everything works fine, but when I deploy to Heroku it gives me an application error with the info to check my heroku logs:
2019-10-11T02:49:50.897584+00:00 heroku[web.1]: State changed from crashed to starting
2019-10-11T02:49:54.670233+00:00 heroku[web.1]: Starting process with command `npm start`
2019-10-11T02:49:56.590749+00:00 app[web.1]:
2019-10-11T02:49:56.590769+00:00 app[web.1]: > sol37.web#1.0.0 start /app
2019-10-11T02:49:56.59077+00:00 app[web.1]: > nuxt start
2019-10-11T02:49:56.590772+00:00 app[web.1]:
2019-10-11T02:49:57.167804+00:00 app[web.1]: ℹ Listening on: http://localhost:49791/ 2019-10-11T02:50:02.00478+00:00 heroku[web.1]: source=web.1 dyno=heroku.149207054.9b940788-6a37-40a9-82de-b19b3519e60c sample#memory_total=55.14MB sample#memory_rss=55.14MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=14487pages sample#memory_pgpgout=1392pages sample#memory_quota=512.00MB
2019-10-11T02:50:23.81059+00:00 heroku[web.1]: source=web.1 dyno=heroku.149207054.9b940788-6a37-40a9-82de-b19b3519e60c sample#memory_total=55.14MB sample#memory_rss=55.14MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=14487pages sample#memory_pgpgout=1392pages sample#memory_quota=512.00MB
2019-10-11T02:50:45.744385+00:00 heroku[web.1]: source=web.1 dyno=heroku.149207054.9b940788-6a37-40a9-82de-b19b3519e60c sample#load_avg_1m=0.00
2019-10-11T02:50:45.762243+00:00 heroku[web.1]: source=web.1 dyno=heroku.149207054.9b940788-6a37-40a9-82de-b19b3519e60c sample#memory_total=55.14MB sample#memory_rss=55.14MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=14487pages sample#memory_pgpgout=1392pages sample#memory_quota=512.00MB
2019-10-11T02:50:54.906637+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
I checked if I set the port somewhere manually, but I'm not doing that anywhere in the project.
Without more information, i tried to build the app on heroku directly.
("heroku run bash" and "npm run build") which gave me the following error.
ERROR in ./pages/index.vue
Module not found: Error: Can't resolve 'sass-loader' in '/app'
and 7 more of those errors all concerning sass-loader.
not sure if "npm run build" works over heroku bash, but at least it gave me some information.
I have another nuxt project that i run on the same heroku instance which works without a problem.
I tried to check what the differences are and i found that it used a lower sass-loader version, which i downgraded on my current project but it's still not working.
After that I tried to run "npm run start" which is what Heroku runs upon deployment. this gave me first an error with nuxtjs/style-ressource, which i realized i don't utilize right now, so i removed that. After that it ran without any issues, but i couldn't get it to show up in the browser.
Does anyone have any idea what else I could try?
Thanks in Advance
Carlo

Heroku App Errors, Nothing in Heroku Logs

I'm getting "We're sorry, but something went wrong."
heroku logs turns up nothing useful from what I can see...
2014-10-06T20:48:04.846089+00:00 heroku[web.1]: State changed from up to starting
2014-10-06T20:48:06.519972+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2014-10-06T20:48:07.928530+00:00 app[web.1]: => Booting Thin
2014-10-06T20:48:07.928582+00:00 app[web.1]: => Rails 4.1.5 application starting in production on http://0.0.0.0:58305
2014-10-06T20:48:07.928584+00:00 app[web.1]: => Run `rails server -h` for more startup options
2014-10-06T20:48:07.928586+00:00 app[web.1]: => Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
2014-10-06T20:48:07.928587+00:00 app[web.1]: => Ctrl-C to shutdown server
2014-10-06T20:48:07.928589+00:00 app[web.1]: Thin web server (v1.6.2 codename Doc Brown)
2014-10-06T20:48:07.928590+00:00 app[web.1]: Maximum connections set to 1024
2014-10-06T20:48:07.928592+00:00 app[web.1]: Listening on 0.0.0.0:58305, CTRL+C to stop
2014-10-06T20:48:07.928593+00:00 app[web.1]: Exiting
2014-10-06T20:48:07.812908+00:00 heroku[web.1]: Starting process with command `bin/rails server -p 49372 -e production`
2014-10-06T20:48:08.659411+00:00 heroku[web.1]: Process exited with status 0
2014-10-06T20:48:11.589427+00:00 heroku[web.1]: State changed from starting to up
Things work fine locally.
Looks like the following got rid of the issue (i thought db migration would happen automatically)
heroku rake db:migrate

Error Deploying to Heroku Play 2.2 app

I think i am having a problem in my Procfile. The deploy is compiled successfully but the app does not start with this message --
2014-03-27T14:17:06.465302+00:00 heroku[api]: Deploy ea0e14d by xxxx#gmail.com
2014-03-27T14:17:06.465378+00:00 heroku[api]: Release v10 created by xxxx#gmail.com
2014-03-27T14:17:14.091032+00:00 heroku[web.1]: Starting process with command `target/universal/stage/bin/enigmatic-dusk-7498 -Dhttp.port=32253`
2014-03-27T14:17:15.199466+00:00 app[web.1]: bash: target/universal/stage/bin/enigmatic-dusk-7498: No such file or directory
2014-03-27T14:17:16.511169+00:00 heroku[web.1]: Process exited with status 127
2014-03-27T14:17:16.521177+00:00 heroku[web.1]: State changed from starting to crashed
The procfile reads:
web: target/universal/stage/bin/enigmatic-dusk-7498 -Dhttp.port=$PORT
which i guess is the standard for play 2.2 onwards.
What is wrong? enigmatic dusk is the name given by heroku to my app. my local name is different.
EDIT:
As per some suggestions i tried changing the procfile to my local app-name.
New Procfile -
web: target/universal/stage/bin/ExampleBootStrap -Dhttp.port=$PORT
Still it fails.
2014-03-27T17:58:12.527528+00:00 heroku[web.1]: Starting process with command `target/universal/stage/bin/ExampleBootStrap -Dhttp.port=38392`
2014-03-27T17:58:13.948429+00:00 app[web.1]: bash: target/universal/stage/bin/ExampleBootStrap: No such file or directory
2014-03-27T17:58:15.608461+00:00 heroku[web.1]: Process exited with status 127
2014-03-27T17:58:15.621947+00:00 heroku[web.1]: State changed from crashed to starting
2014-03-27T17:58:15.620997+00:00 heroku[web.1]: State changed from starting to crashed
2014-03-27T17:58:27.265083+00:00 heroku[web.1]: State changed from starting to crashed
2014-03-27T17:58:24.366648+00:00 heroku[web.1]: Starting process with command `target/universal/stage/bin/ExampleBootStrap -Dhttp.port=33223`
2014-03-27T17:58:25.666535+00:00 app[web.1]: bash: target/universal/stage/bin/ExampleBootStrap: No such file or directory
2014-03-27T17:58:27.250296+00:00 heroku[web.1]: Process exited with status 127
In your procfile, you must replace enigmatic-dusk-7498 with the name of your play project in lower case letters, not you heroku app.

Resources