updateserver.php 981 B

1234567891011121314151617181920212223242526
  1. B1;95;0c<?php
  2. error_reporting(E_ALL);
  3. header("Content-type: text/html; charset=utf-8");
  4. $p = json_decode($_REQUEST["hook"]); // json转换
  5. $fp = fopen("./log.txt", 'a');
  6. $lastcommit = $p->push_data->commits[count($js->push_data->commits) - 1];
  7. print_r($_SERVER);
  8. echo "<br>\n---- PRINTENV ----- \n\n<br>";
  9. echo exec("printenv", $res2);
  10. var_dump($res2);
  11. echo "<br>\n---- RUNNING : sudo supervisor start all ----- \n\n<br>";
  12. echo exec("sudo supervisorctl restart all ", $res3);
  13. echo "\n<br>";
  14. var_dump($res3);
  15. echo "<br>";
  16. echo "cd /home/nginx/quiz/quizapp-be && git pull ; git log --graph --oneline";
  17. echo exec("cd /home/nginx/quiz/quizapp-be && git pull ; git log --graph --oneline", $res4);
  18. for($i=0;$i<count($res4);$i++){
  19. echo $res4[$i] . "<br>\n";
  20. }
  21. echo "<br>";
  22. fwrite($fp, "※" . date('Y-m-d H:i:s') . "\t" . $lastcommit->message . "\t" . $lastcommit->author->name . "\n"); // 进行记录
  23. fclose($fp);
  24. ?>