服务中的定时器
我们最近在我们的软件中添加了一项新功能 - 为上传并存储在服务器上的文档生成预览。 我们通过以下方式做到这一点:
- 用户上传文档;
- 一旦用户打开文档信息卡,就会发布最近上传的文档的预览(预览生成的信息存储在数据库表中);
- 我们的服务每 30 秒启动一次,检查预览表并启动预览生成过程。
我现在面临的问题是 - 用于生成预览的新代码使用了我们的一些旧代码,有时会“冻结”Word 或 Excel 进程。 预览的生成停止,并且所有后续预览都保持在“待处理”模式,直到我终止 Word、Excel 进程(我们测试 MS Office 文档的预览)。 终止进程后,预览生成将继续。
我正在考虑在我们的服务中实现计时器,这样如果服务在预览生成开始后等待时间超过 1 分钟,它应该终止该进程并继续生成其他文档的预览。
我遇到的主要问题是,我无法像处理其他文档那样“移动”对遗留代码的调用以单独的进程(例如,我们通过 Process'es 使用 GhostScript 实现了 .ps 文件生成)。
关于如何“处理”对遗留代码的调用有什么想法吗?
we have recently added a new feature to our software - preview generation for documents that are uploaded and stored on the server. We did this the following way:
- The user uploads a document;
- Once the user opens the document information card, the preview for the recently uploaded document is issued (the info regarding the preview generation is stored in a db table);
- Every 30 seconds our service starts, reviews the preview table and initiates the preview generation procedures.
The problem that I am facing now is this - the new code for generating previews uses some of our legacy code and it sometimes "freezes" the Word or Excel processes. The generation of preview stops and all the following previews stay in "pending" mode until I kill the Word, Excel processes (we test the preview for MS Office documents). After I kill the processes, preview generation continues on.
I was thinking of implementing timers into our service so that if a service is awaiting for more that 1 minute after the preview generation has been started, it should kill the process and continue on with generating previews for other documents.
The main problem that I have is that i can not "move" the calls to our legacy code to separate processes as we have done with other documents (for example, we have implemented .ps file generation with GhostScript via Process'es).
Any ideas on how to "processify" the calls to legacy code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以创建第二个进程作为第一个进程的看门狗吗?
或者您可以使第一个进程自动重新启动,并让第二个计时器线程监视它,然后终止它自己的进程吗?
Can you make a second process which is a watchdog on the first process?
Or can you make the first process auto-restart, and have a second timer thread that monitors it and then kills its own process?