I know it's not the nice way, but does anyone of you know a service where I can run a heartbeat to my heroku application and if it fails for a couple of minutes to respond to call heroku restart and send me an email?
Would be a really nice feature for me...
Thanks a lot!
Cheers!
Restarting the app would definitely not be the best solution.
heroku isn't 100% of the time available
See their status page.
There is pingdom though, which will ping your app and notify you if it is down.
But won't take any action for you.
Related
I want just 1 trade open at a time. But Heroku force my bot to open another trade each time my bot "crashes" because Heroku restarting my bot again.
How can avoid this and "tell" Heroku to doing nothing if I already have an open trade?
I had to turn off the web dynos
This is not Heroku's fault. Heroku will always try to keep you application up, that's the deal with using such services. So if it crashes, it will restart.
You should check on your own application to only open a trade if there isn't one already.
for my jelastic servers as i dont use much would like to put them in something similar to sleep, that they are only activated in http request
i saw for trial accounts sleeps something, but would like to know if there would be a way to do it with a normal account.
For instance i had the idea of making a script to turn them off at night, but i dont know how to wake up.
any ideas are welcom
https://ops-docs.jelastic.com/jca-sleep-results
https://ops-docs.jelastic.com/jca-sleep-results
There is a start stop scheduler in the marketplace within the Jelastic dashboard. Check "Env Start/Stop Scheduler" in Marketplace > Add-Ons.
If you're interested in the code, or can't find that add-on at your Jelastic provider, you can find it at https://github.com/jelastic-jps/start-stop-scheduler
Note that this is not quite the same as sleep (it will not wake up automatically when there's a http request) - it will be completely offline during the hours that you specify.
I want to use Telegram Bot with enabled webHook,
Can I use Heroku free plan as my Bot's Url to hook up when received text message ?
I'm using Nodejs as language.
Yes, you can and it works fine. But Heroku will try to freeze your app for some time. In fact it can't be active for more than 18 of the last 24 hours.
And if you will prevent it, with ping your app or your bot will continuously receive messages, your app will recharge next 6 hours. It's a limit of the free plan.
I suggest that you use Openshift, it doesn't have such limits in free tier.
I guess another suggestion I can make is for you to use glitch.
I use glitch for all the bots I have made so far, it's free, easy to get started with. It also has the limitation where it sleeps after 5 minutes of your bot not being active.
In a post they say the reason why and how to solve it:
Apps sleeping is a large reason why we can offer the Glitch service
for free, so it’s not something we can turn off. However, we accept
that for some use-cases, like bots with no webhooks support, that’s
not ideal. It’s possible to expose a route in your app that a web cron
service or uptime monitoring service can hit and cause your bot to
wake. Doing that every 5 mins or so should do what you want.
Hope it helps.
I have a couple of telegram bots hosted on Heroku's free plan, with webhooks active.
They work fine but as mentioned in other answers the app is put to sleep after 30 minutes of inactivity: webhooks will reactivate it but when waking up there will be some lag and rarely some malfunctions (I lost a couple of commands).
There is a monthly limit of usage time but unless the bot is heavily used I found that this has not ever been a problem.
All in all I like the service, especially since it is free.
I'm trying to debug an API issue I have that occurs when my app tries to access a sleeping Heroku Dyno. The problem is it takes a while for a dyno to naturally sleep so it really slows down the debug process.
I know how to turn off a dyno but the bug I'm try to fix seems to happen when the app makes a request to a sleeping dyno that doesn't immediately respond, yet eventually responds.
I got the definitive answer from a Heroku engineer. It's no, you can't force a dyno to sleep.
I have a sinatra app deployed at heroku, and I have scaled web worked to 3 dynos, so requests are being served by
web.1
web.2 and
web.3 respoectively.
I want to know in ruby, from within a conroller action that current request is being served by which dyno and then want to keep this in database. I did a bit of google but not found any satisfactory answer.
Any Help would be greatly appreciated.
Thanks
There is really no way to know this. You don't get any HTTP headers from Heroku that specify which Dyno is handling the request, so there's no way to tell. The best you can do is have Heroku stream all your logs somewhere (syslog drain) so that you can parse the logfiles and match request URIs to Dynos.
There's probably a very hacky way to do this on boot with a worker process.
You need to be able to monitor the output from heroku logs --tail, see https://github.com/dblock/heroku-commander for an example. The worker reads logs.
The worker makes an HTTP request to the app, eg. GET app/dyno?id=uuid1. The response is the MAC address of the dyno that responded, eg. mac1.
The worker can see in the logs that uuid1 went to web.5, which responded with its mac. Bingo, the worker now knows.
PUT app/dyno?mac1=web.5&mac2=web.6, etc. Each dyno that receives this will compare its mac to one of the macs and respond true/false that it now knows who it is.
Repeat until the worker has reached all dynos and all dynos know.
Watch for dyno restarts periodically.
You got to wonder though why you need to know that you're "web.1". Why can't it be a unique UUID, like the MAC address of the machine?