Guest User

Untitled

a guest
Feb 11th, 2016
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. <?php
  2. /
  3. * @component to write sample script which will pass to backend jobs
  4. *
  5. */
  6.  
  7. App::uses('Component', 'Controller');
  8. class BackgroundScriptComponent extends Component {
  9.  
  10. public function crawllUrls($crawling) { // Passing 200 urls to crawl
  11.  
  12. for ($i = 0; $i < $Counter; $i++) {
  13.  
  14. /*
  15. Internal code which is running perfect using browser hit
  16. */
  17.  
  18. }
  19. }
  20. }
  21.  
  22. /* @component to write sample script which will pass to backend jobs */
  23.  
  24. Controller:
  25.  
  26. class ScriptController extends AppController {
  27.  
  28. public $components = array('BackgroundScript');
  29.  
  30. public function CreateBackendProcess() {
  31. $this->layout = false;
  32. $this->autoRender = false;
  33.  
  34. $arrOfUrls = array('500 url there in this array');
  35.  
  36. //echo $this->BackgroundScript->crawllUrls($crawling); // This line having Component method call. I do not want to call this as same as.. It should call from CLI
  37.  
  38. $cmd = ""; //what should come in this $cmd to calls BackgroundScript's crawllUrls() method component which will pass to exec()
  39.  
  40. exec($cmd, $pid);
  41.  
  42. echo "<br />Script Running with process id " . json_encode($pid); //I will save this PS ID to database
  43. exit;
  44. }
  45. }
Add Comment
Please, Sign In to add comment