Why did you publish the Python app using LINE Notify on heroku, but it runs on its own?

Asked 2 years ago, Updated 2 years ago, 122 views

We have published a Python app to heroku that informs her of information scraped from the web using LINE Notify.

Line gets notified when it runs periodically, even though you don't even use the scheduler.

Is it heroku specification?

The plan is a free plan.
I've heard that heroku's free plan will be restarted.

Is main.py running at the time of reboot?

Added code.(main.py)

import requests
from bs4 import BeautifulSoup
import urllib.request

r=requests.get("***********")

soup = BeautifulSoup(r.content, "html.parser")

css1=soup.find_all("p", class_="top-text")
t_text=css1[0].getText()


msg = t_text

LINE_TOKEN="*************"
LINE_NOTIFY_URL="****************"

def send_jt_information(msg):
    method="POST"
    headers={"Authorization":"Bearer%s"%LINE_TOKEN}
    payload = {"message":msg}
    try:
        payload=urllib.parse.urlencode(payload).encode("utf-8")
        requ=urllib.request.Request(
            url=LINE_NOTIFY_URL, data=payload, method=method, headers=headers)
        urllib.request.urlopen(req)
    except Exception as:
        print("Exception Error:",e)
        sys.exit(1)

defmain():
    send_jt_information(msg)


if__name__=='__main__':
    main()

python python3 heroku line

2022-09-29 22:16

1 Answers

This part of the official document may be helpful.

https://devcenter.heroku.com/articles/dynos#restarting

Dynos are also restarted (cycled) at least once per day to help maintain the health of applications running on Heroku. Any changes to the local filesystem will be deleted. The cycling happens once every 24 hours (plus up to 216 random minutes, to prevent every dyno for an application from restarting at the same time). Manual restarts (heroku ps:restart) and releases (deploys or changing config vars) will reset this24 hour period.

In the case of the questioner, it says every 6 hours, but since it says at least once per day, it seems that the specification does not specify exactly how many hours it will be restarted.


2022-09-29 22:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.