Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys,
As i know, heroku dyno will be restarted once a day. In my application, .txt file usually is updated. How can i keep it after dyno restared ?

Thanks.

What I have tried:

right now , i tried to save it by sending email. But i have to update it after restarting.
Posted
Updated 3-Aug-16 15:53pm

1 solution

Why don't you persist the file in a local file storage, right on the server itself. When the service restarts, it removes content from temporary memory only. The files on the disk are not removed. So that is why I would recommend save that text file on the primary disk itself.

Secondly, also communicate with the web server admins on your hosting provider to know how they would recommend storing these files as. Every server has its own configurations to perform a clean up.

Edit

Right, I have just read about the process, and more here[^], the way I see this is that their entire local system for storing the data is a temporary storage and only your code remains. In this case, the only bid you have is to upload the file somewhere else — on a third-party storage account. You might to handle these events. In mosts cases, I like Microsoft Azure as it provides a lot of control over your content and lets you control when your application restarts and you can then handle these events in your application code. Whereas in their documentation I haven't found this event handler.

If you can find that handler, I would recommend using that handler to upload file.
 
Share this answer
 
v2
Comments
baotdinh 3-Aug-16 22:17pm    
thank for your reply. maybe i do not understand but i think the file .txt i mentioned . it is inside my project . is it a local file you said. i see it is backed to the last version i deployed.
Afzaal Ahmad Zeeshan 3-Aug-16 22:19pm    
I wonder why would they revert your files to the initial versions that they had once they were deployed. I would recommend contacting their team to know whether server is doing this, or did you misplace the files and placed them somewhere they didn't need to be.
baotdinh 3-Aug-16 23:34pm    
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.
I think it is already clear in their document.
Afzaal Ahmad Zeeshan 4-Aug-16 0:40am    
Sadly, there isn't much left on their end to dig into and you have already made a good research effort.

However, I was unable to determine the event that handles how the system restarts. If you can find that one, please handle the function to upload the file to some secure location where file might persist.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900