简体   繁体   中英

Heroku dyno not writing to file

I have a bot running on Heroku. This bot has some 'actions' that it is supposed to execute (those are dummies, just testing if everything is alright) and then write to file whatever action it did.

The funny thing is that on my local machine, after 6-8 hours of testing I had 3 entries (3 actions performed), but on Heroku the bot has been running for a day now, and no entries are present (thought this was Heroku's issue, but with both cat and stat it shows that the file is empty).

This is how I save the data to file:

 f = open('actions.txt', 'a')
 f.write(action)

Those are the file ( actions.txt ) permissions: 600

I just want to store the actions the bot performed over a week or so to make sure everything is working well.

I just want to store the actions the bot performed over a week or so to make sure everything is working well

In that case you'll need a different approach to data persistence. Heroku's ephemeral filesystem loses whatever changes you make to it every time your dyno restarts, which happens at least once per day .

A simple solution might be to store your data in PostgreSQL, which Heroku supports out of the box . If you prefer other databases there are many to choose from .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM