Search code examples
perlweb-applicationsweb-frontendinter-process-communicat

Recommended communication pattern for web frontend of command line app


I have a perl app which processes text files from the local filesystem (think about it as an overly-complicated grep). I want to design a webapp which allows remote users to invoke the perl app by setting the required parameters. Once it's running it would be desirable some sort of communication between the perl app and the webapp about the status of the process (running, % done, finished). Which would be a recommended way of communication between the two processes? I was thinking in a database table, but I'm not really sure it's a good idea.

any suggestions are appreciated.


Solution

  • Stackers, go ahead and edit this answer to add code examples or links to them.

    DrNoone, two approaches come to mind.

    1. callback

      Your greppy app needs to offer a callback function that returns the status and which is periodically called by the Web app.

    2. event

      This makes sense if you are already using a Web server/app framework which exposes an event loop usable from external applications (rather unlikely in Perl land). The greppy app fires events on status changes and the Web app attaches/listens to them and acts accordingly.


    For IPC as you envision it, a plain database is not so suitable. Look into message queues instead. For great interop, pick AMPQ compliant implementation.