How do i shutdown my heroku app? - heroku

I've slowly battled through to the point where I have a working Grails app on Heroku. I'm going to bed now so I want to shut it down so I don't continue to use up my 750 free hours of my Dyno. It is probably obvious but I can't find how to shutdown my Heroku web server and restart it again in the morning.

To shut down your Heroku app scale the web processes to 0:
heroku ps:scale web=0
See the Usage & Billing dev centre article: "A web dyno that is idled continues to accrue usage". I believe maintenance mode will continue to accrue time; it simply serves a static page to visitors instead of serving your app.
Keep in mind each app receives 750 free billing hours per month. Depending on your intended usage, this may mean you don't need to shut down (i.e. if you only plan to run a single dyno for the whole month).

From web:
Personal => Your App Name => Overview => Configure Dynos => Click on edit against web => Flip the switch => Confirm

To stop a DYNO you can use:
heroku ps:stop "appname"
To get list of running appnames you can use:
heroku apps

Just read the documentation:
https://devcenter.heroku.com/articles/one-off-dynos#one-off-dynos
Type
heroku ps
to see all running app associated to you account, with an id associated, then
heroku ps:stop run.1
if the app you want to stop has the 1 id.
Note that the maintenance mode will not stop your app. Mine was wrongly configured and continued to crash with the maintenance mode enabled.

There's a Maintenance Mode in Settings now in 2019.

Maybe turn on maintenance mode? heroku maintenance:on

You can use the add-on AutoIdle to automatically shutdown:
https://elements.heroku.com/addons/autoidle

Related

Why my trading bot is being restarting after I made a sys exit on my python module?

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.

Stop Heroku Dyno from cycling

I have a Hobby Dyno that hosts an application in Heroku in which users can upload images.
What I've noticed is the Dyno restarts during his cycle causing all images to be gone.
2018-07-27T16:23:09.914767+00:00 heroku[web.1]: Cycling
2018-07-27T16:23:09.915421+00:00 heroku[web.1]: State changed from up to starting
I am aware of solutions that involve a third-party storage or host the app in another platform altogheter.
I am wondering if there is a way to stop a dyno cycle and never make it restart such as is always in the up state?
Thank you.
There is no way to prevent dyno cycling. Heroku does this automatically at least once per day.
Heroku's entire design is based on The 12-Factor App, which states that your app's processes are disposable. Heroku accomplishes this (in part) with its ephemeral file system, which is why you must persist files using an external service.

How can I push to Heroku, and still keep the web app live?

Say for example you had two web dynos set up for your account (0 worker dynos).
To save on switching to maintenance mode, how would one push to one web dyno, and then the other update once the first has finished booting?
You can't do that - pushing to Heroku will result in both dynos being restarted with the contents of the new slug.
However, there is a labs feature called preboot (https://devcenter.heroku.com/articles/labs-preboot) which might accomplish exactly what you want.

How can I use Heroku's scheduler to run jobs in a 2X sized dyno?

I would like to use Heroku's scheduler addon to run a job on a large size Heroku dyno. Is this possible? and if so, how?
This is not currently possible however it's high on the requested list of features for 2X dynos and Heroku is looking into it.
Heroku now supports choosing your dyno size on Heroku Scheduler (see Heroku Documentation )
On the Scheduler Dashboard, click “Add Job…”, enter a task, select a frequency, dyno size, and next run time.
This feature was added June 6th, 2013 (see Heroku Changelog)

Will my Heroku app working on 1 web dyno stay active if I pay for 1 worker dyno?

I currently have an app deployed on Heroku which runs on two web dynos so it won't go to sleep if it remains inactive for a certain time.
Now if I scale it down to only one web dyno (free) and instead pay for one worker dyno, will Heroku always keep my app active?
It will still idle - you NEED to have more than a single web dyno
https://devcenter.heroku.com/articles/dyno-idling
You can also use the New Relic add-on to monitor your app and keep it alive. There is a tab in settings to configure availability monitoring.
You can also avoid a single web dyno from idling by using a monitoring service like pingdom.com since it's periodically sending a request to your web dyno.
Try Pingdom. Free plans include one website check. I use this service to keep my app active all the time.
Pingdom tests your websites and other infrastructure components as
often as every minute to make sure it is all up and running.
From Pingdom Homepage
Pingdom does this by "pinging" or rather requesting a resource from your website on a regular interval. This has the side effect of keeping your website "active", cache's primed, etc.. because your website is seeing regular "traffic" (the requests coming from pingdom).
Try Un-idler. You don't need to sign in and it's free.
http://unidler.herokuapp.com/
You can try http://kaffeine.herokuapp.com/ it will ping your app every 30 minutes so your app won't go to sleep.
Try CloudUp. It visits your apps periodically to keep them awake. It is free, and you can add as many apps as you want. It also activates apps on Google App Engine and Azure.

Resources