应用程序设计 - 带网页前端的守护进程

发布于 2024-07-23 09:56:26 字数 436 浏览 4 评论 0原文

我有一个应用程序,每五秒扫描一次输入目录,当作业(即文件)放置在该目录中时,应用程序会读取它,处理它并在输出目录中输出另一个文件。

我的问题是,如果我想在这个应用程序上放置一个基于 Web 的前端,我将如何等待处理完成?

  • 用户提交作业
  • 作业被放置在输入目录中
  • ......我在网页上做什么?
  • 处理发生
  • 输出文件生成
  • ......我如何知道作业已完成?

我提出的两个解决方案是:

  • 每 x 秒从网页轮询输出目录
  • 使用 ajax 轮询 Web 服务或网页,报告输出文件是否存在

服务器是否有更好的设计? 换句话说,TCP 或命名管道在这种情况下有何帮助? (由于 DCOM 对象而无法使用远程处理。)

I have an application that scans an input directory every five seconds and when a job (i.e. file) is placed in the directory the application reads it, processes it and outputs another file(s) in an output directory.

My question is, If I wanted to put a web based front end on this application, how would I wait for the processing to be complete?

  • User submits job
  • job is placed in input directory
  • ......What am I doing on the web page here?
  • processing occurs
  • output file is generated
  • ......How do I know that the job is finished?

The two solutions I came up with were:

  • poll output directory every x seconds from the webpage
  • use ajax to poll a webservice or webpage that reports back whether the output file is present

Is there a better design for the server? In other words, how would TCP or Named Pipes help in this situation? (Cannot use remoting due to a DCOM object.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

司马昭之心 2024-07-30 09:56:27

我不认为命名管道会让 Web 客户端自动轮询变得更容易,但它可能使服务器能够更好地通知另一个进程转换已完成,并最终将消息排队到网页浏览器。

您可以尝试让 Web 客户端每隔几秒轮询一次,以查看文件处理是否已完成,或者您也可以使用 Juggernaut 之类的“推送”命令到页面。 Juggernaut 使用 Flash 在 Web 浏览器上打开一个套接字,不断从服务器提供 JavaScript。 它可能负责发送命令来提醒浏览器文件已完成,然后发出重定向。

I don't think that Named Pipes are going to make it any easier to get the web client to poll automatically, but it might make the server better able to notify another process that the conversion has completed--and ultimately queue a message to the web browser.

You can try having the web client poll every few seconds to see if the file process has completed, alternatively you could have something like Juggernaut "push" commands out to the page. Juggernaut works using Flash to open a socket on the web browser that continually feeds JavaScript from the server. It could be responsible for sending a command to alert the browser that the file has completed and then issue a redirect.

蘸点软妹酱 2024-07-30 09:56:26

我们过去在商业上完成的一个解决方案基本上是守护进程写入日志(通常是数据库),并带有日期/时间戳,说明其正在做什么,而 Web 前端仅显示日志中最新的 X 条条目,使用一个小开关来隐藏所有“在目录中查找,未找到文件”消息,效果相当好,我们后来使用 AJAX 对其进行了升级(每 20 秒重新加载一次的计时器)。

A solution we have done commercially in the past is basically the daemon writes to a log (typically DB), with a date/time stamp, about what its doing, and the web frontend just shows the latest X amount of entries from the log, with a little toggle to hide all of the "Looked in directory, no file found" messages, worked fairly well, we upgraded it later on with AJAX (Timer that reloaded every 20 seconds).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文