如何在一天中的特定时间安排Heroku(维护模式或充电)?

时间:2021-05-27 14:36:35

I'm trying to keep my Heroku (free) application awake during daytime. I don't really care if it sleeps late at night.

我想在白天保持我的Heroku(免费)应用程序清醒。我不在乎它是否在深夜睡觉。

The old technique of continuously pinging the app is no longer a valid solution because since 2015, all free-app's have to sleep at least 6 hours a day.

持续ping应用程序的旧技术不再是有效的解决方案,因为自2015年以来,所有免费应用程序必须每天至少睡6个小时。

I'd like to know if any of you guys figured this out before.

我想知道你们之前是否有人想过这个。

I need to schedule the recharge state or maintenance mode in a specific time range.

我需要在特定时间范围内安排充电状态或维护模式。

Let's make this question and an up-to-date resource of accomplishing this task.

让我们提出这个问题,以及完成这项任务的最新资源。

Please submit only constructive ideas.

请仅提交有建设性的想法。

2 个解决方案

#1


6  

You can just scale it down for the six hours you want it to be asleep:

您可以将其缩小至您希望它睡着的六个小时:

heroku scale web=0

Then scale it back up when you want to wake it up:

然后在想要将其唤醒时将其缩小:

heroku scale web=1

There are a lot of ways to implement this; a script on some other machine would work fine, but you could probably also use the Heroku Platform API and a scheduler service:

有很多方法可以实现这一点;在其他一些机器上的脚本可以正常工作,但您也可以使用Heroku Platform API和调度程序服务:

disclosure: I'm the Node.js Platform Owner at Heroku

披露:我是Heroku的Node.js平台所有者

#2


4  

There is also this add-on: https://devcenter.heroku.com/articles/process-scheduler

还有这个附加组件:https://devcenter.heroku.com/articles/process-scheduler

At first I thought it wasn't working as it doesn't seem to necessarily run right at the top of the hour, but other than that it's been working really well for me and allows me to sleep my app overnight.

起初我觉得它不起作用,因为它似乎不一定在最佳时刻运行,但除此之外它对我来说真的很好,并允许我一夜之间睡觉我的应用程序。

#1


6  

You can just scale it down for the six hours you want it to be asleep:

您可以将其缩小至您希望它睡着的六个小时:

heroku scale web=0

Then scale it back up when you want to wake it up:

然后在想要将其唤醒时将其缩小:

heroku scale web=1

There are a lot of ways to implement this; a script on some other machine would work fine, but you could probably also use the Heroku Platform API and a scheduler service:

有很多方法可以实现这一点;在其他一些机器上的脚本可以正常工作,但您也可以使用Heroku Platform API和调度程序服务:

disclosure: I'm the Node.js Platform Owner at Heroku

披露:我是Heroku的Node.js平台所有者

#2


4  

There is also this add-on: https://devcenter.heroku.com/articles/process-scheduler

还有这个附加组件:https://devcenter.heroku.com/articles/process-scheduler

At first I thought it wasn't working as it doesn't seem to necessarily run right at the top of the hour, but other than that it's been working really well for me and allows me to sleep my app overnight.

起初我觉得它不起作用,因为它似乎不一定在最佳时刻运行,但除此之外它对我来说真的很好,并允许我一夜之间睡觉我的应用程序。