Run newrelic on heroku clock dyno that runs python file - heroku

I have both web and clock dynos on Heroku but I see only web host on new relic but not the clock. How do I run newrelic on both?
Web works with newrelic-admin run-program gunicorn wsgi --log-file -
tried newrelic-admin run-python test.py but couldn't get any data on new relic.

Related

How to look Gunicorn logs when it running?

I deployed a Flask application to a VPS, and using Gunicorn as a web server.
And I running the Gunicorn server using this command:
gunicorn --bind=0.0.0.0 run:app --access-logfile '-'
With the command I can see the log running. But after I closed my terminal session, I want to see the running logs again.
In Heroku I can use heroku logs -t to do that, any similar way to see it on Gunicorn..?
You need to set up the supervisor. Supervisor keeps your server running mode and saves your log. setup the supervisor file below and then you can see the logs:
[program:your_project_name]
command=/home/your_virualenv/bin/gunicorn --log-level debug
run_apiengine:main_app --bind 0.0.0.0:5007 --workers 2 --worker-class gevent
directory=your_project_directory
stdout_logfile= your_log_folder_path/supervisor_stdout.log
stderr_logfile= your_log_folder_path/supervisor_stderr.log
user=your_user
autostart=true
PYTHONPATH="$PYTHONPATH:your_python_path";OAUTHLIB_INSECURE_TRANSPORT='1';

Change Meteor Node-Inspector web-port

I need to change the web-port used by node-inspector when debugging Meteor but it seems to always run on 8080, which is where I need to run the Meteor web app.
I've tried setting the NODE_OPTIONS environment variable before running Meteor:
$ export NODE_OPTIONS=--debug=47977
$ meteor debug --port=8080
[[[[[ ~/.../src ]]]]]
=> Started proxy.
=> Started MongoDB.
Starting your app -
Your application is now paused and ready for debugging!
To debug the server process using a graphical debugging interface,
visit this URL in your web browser:
http://localhost:8080/debug?port=5858
Paused at /.../src/.meteor/local/build/main.js:7
Cannot start the server at 0.0.0.0:8080. Error: listen EADDRINUSE.
There is another process already listening at this address.
Run `node-inspector --web-port={port}` to use a different port.
I've tried running node-inspector separately on a different web port then starting meteor, but meteor always seems to also try starting node-inspector on 8080:
$ node-inspector --web-port=47977 &
[1] 74439
$ Node Inspector v0.5.0
info - socket.io started
Visit http://127.0.0.1:47977/debug?port=5858 to start debugging.
$ meteor debug --port=8080
[[[[[ ~/.../src ]]]]]
=> Started proxy.
=> Started MongoDB.
Starting your app -
Your application is now paused and ready for debugging!
To debug the server process using a graphical debugging interface,
visit this URL in your web browser:
http://localhost:8080/debug?port=5858
Paused at /.../src/.meteor/local/build/main.js:7
Cannot start the server at 0.0.0.0:8080. Error: listen EADDRINUSE.
There is another process already listening at this address.
Run `node-inspector --web-port={port}` to use a different port.
Note, there are 3 ports in play here:
8080 - Web port running Meteor web app.
47977 - Web port I want to run node-inspector web app.
5858 - Port used to communicate between the other 2 processes.
I need Meteor to be running on 8080 but can't seem to stop Meteor starting node-inspector on 8080 too. I've also tried a few other ports for node-inspector but with the same results.
Running on Mac with Meteor 1.2.1
I had the same problem, i've solved by:
in terminal run node-inspector --web-port=47977
and in a new terminal run meteor debug
go to http://127.0.0.1:47977/ws=127.0.0.1:47977&port=5858 to start debugging.

New relic + gunicorn + https issues

I am currently using new relic to monitor my web app. In my deploy script i have the following
sudo NEW_RELIC_CONFIG_FILE=/<path to app>/app/config/newrelic.ini newrelic-admin run-program gunicorn 'run:run_app' -b 0.0.0.0:8000 -w3 --certfile=/<path to app>/app/config/server.crt --keyfile=/<path to app>/app/config/server.key --access-logfile log/gunicorn.log
The idea here is to allow for https. When testing locally I can get the https working with
sudo gunicorn 'run:run_app' -b 0.0.0.0:5000 -w3 --certfile=app/config/server.crt --keyfile=app/config/server.key --access-logfile gunicorn.log
And the debugger shows
[INFO] Listening at: https://0.0.0.0:5000 (4691)
in the local case, and
[INFO] Listening at: http://0.0.0.0:8000 (9094)
on the server.
I've tried everything I could think of and think that this must be a problem in New Relic overriding something?
This isn't quite enough information to go on. You might want to open a ticket at https://support.newrelic.com so that New Relic can investigate this at length.

Heroku Boot Timeout (Error R10)

Every time I launch my app it cannot get past the 60 second point without:
2012-05-06T22:41:11+00:00 heroku[web.1]: Stopping process with SIGKILL
2012-05-06T22:41:11+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2012-05-06T22:41:11+00:00 heroku[web.1]: Process exited with status 137
2012-05-06T22:41:12+00:00 heroku[web.1]: State changed from starting to crashed
Here is my Procfile:
web: bundle exec thin start -p $PORT
Any responses will be thoroughly appreciated.
If your app does take longer than 60 seconds for "good" reasons, you can work around the 60s boot time limit with https://github.com/dblock/heroku-forward.
The solution was that I had forgotten to include the -p $PORT in my Procfile line.
in Procfile change:
web: bundle exec thin start
to
web: bundle exec thin start -p $PORT
That fixed it for me.
Heroku's boot timeout bit me too. I read several blog posts about how to get around it and ended up automating some of the solutions into a gem.
To reduce the startup time on deploy, you can trim the gems loaded at boot time (this doesn't mean you have to trim them from the app, just boot time).
gem_bench evaluates which gems are likely to not be needed at boot time.
I have an app with about 250 gems and was able to add :require => false to about 60 of them, with dramatic effects.
https://github.com/acquaintable/gem_bench
Disclaimer: I am the author of this open source ruby gem. I wrote the gem to aid myself in solving this exact problem: the 60 second timeout on Heroku.
Hi i was facing the same issue.I have resolved this issue by increase the timeout in /config/unicorn.rb
change timeout 15 to timeout 20 in /config/unicorn.rb
In my case using nodejs I solved this adding a Procfile file with content:
worker: node index.js and push it to heroku.
After that make sure to disable the check "web npm start" and turn on the check "worker node index.js" just like the image attached below
herokuResourcesConfig
I was having the same error when deploying my Node app on Heroku.
I got it solved by adding a Procfile.
web: node app.js
It tells Heroku how to start the application.
The error is because of Heroku is not able to configure on which PORT to run the application.
It can be solved by specifying the PORT for Heroku, ie: in app.js
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`App is running on port ${ PORT }`);
});
Error R10 (Boot timeout)
is this hidden section of heroku allows you to increase the deployment time.
https://tools.heroku.support/limits/boot_timeout
I got this error because Heroku didn't have access to the Mongo Atlas database. You need to change this in the database settings
have the same issue, solved by creating file with proxy server
https://www.npmjs.com/package/http-proxy#setup-a-basic-stand-alone-proxy-server
proxy.js:
httpProxy.createProxyServer({
target, // target that can't cant be exposed, e.g. localhost:4000
changeOrigin: true,
}).listen(process.env.PORT); // port from heroku runtime
then
node server/proxy.js

How can I tell how many worker dynos I'm using on Heroku?

I'm using HireFireApp to autoscale my web and worker dynos on Heroku. However, when I navigate to the Resque app on my application it says
"0 of 46 Workers Working"
Does this mean that I'm using 46 worker dynos???
Update:
Running heroku ps shows:
web.1 up for 21m bundle exec thin start -p $PORT
worker.1 starting for 1s bundle exec rake resque:work QUEUE..
From the command line in your heroku app have a look at the output of
heroku ps
that will show you how many workers you are running.

Resources