在heroku dyno重启后保留数据 [英] Keep data after heroku dyno restart

查看:128
本文介绍了在heroku dyno重启后保留数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

据我所知,heroku dyno将每天重启一次。在我的应用程序中,.txt文件通常会更新。在dyno恢复后如何保持它?



谢谢。



我尝试过什么:



现在,我试图通过发送电子邮件来保存它。但是我必须在重新启动后更新它。

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.

推荐答案

为什么不将文件保存在本地文件存储中,就在服务器本身上。服务重新启动时,它仅从临时内存中删除内容。磁盘上的文件不会被删除。所以我建议将该文本文件保存在主磁盘本身上。



其次,还要与您的托管服务提供商的网络服务器管理员沟通,以了解他们如何建议将这些文件存储为。每个服务器都有自己的配置来执行清理



编辑



对,我刚看过这个过程,还有更多这里 [ ^ ],我看到的方式是他们用于存储数据的整个本地系统是临时存储,只剩下您的代码。在这种情况下,您唯一的出价是将文件上传到其他地方 - 在第三方存储帐户上。您可以处理这些事件。在大多数情况下,我喜欢Microsoft Azure,因为它提供了对内容的大量控制,并允许您控制应用程序重新启动的时间,然后您可以在应用程序代码中处理这些事件。而在他们的文档中我没有找到这个事件处理程序。



如果你能找到那个处理程序,我建议使用该处理程序上传文件。
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.


这篇关于在heroku dyno重启后保留数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆