Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 12th, 2012  |  syntax: None  |  size: 1.17 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to build php triggerable service
  2. run php as service where php may run without being connected to client
  3. php execution can be triggered using http request by client
  4. php (continuous or triggered) have full access to the resources
  5. php can send the data from the resources to the client on response
  6.        
  7. - 15:55:00 The master script runs. SELECT worktodo FROM thingstodo returns nothing
  8. - 15:56:00 The master script runs. SELECT worktodo FROM thingstodo returns nothing
  9. - 15:56:17 The client runs; it is a request for data from serial port.
  10. - 15:56:17 The request is stored in the DB and gets ID 12345 and status "WAITING"
  11.        
  12. Location: http://mylocation/script.php?check=12345
  13.        
  14. - 15:57:00 The master script gets awakened and finds there is one job in WAITING status; updates it in LOCKED status and places its own IP and PID in the proper fields, then decodes the work details, sees what needs to be done and does it.
  15. - 15:57:33 The work is done and the row gets updated again; now STATUS=COMPLETED
  16. - 15:57:35 Meanwhile the client gets called again, but this time it finds COMPLETED, so happily fetches the data and shows it to the customer, also deleting the row not to clutter the DB.