From 04be9ed134dcc4229a26b1aad720ddeb18cb5f12 Mon Sep 17 00:00:00 2001 From: ospek project Date: Sat, 10 Mar 2018 23:46:11 +0000 Subject: [PATCH] update --- .gitignore | 5 +++ .travis.yml | 25 +++++++++++ LICENSE | 21 ++++++++++ appveyor.yml | 37 ++++++++++++++++ asset/icon.png | Bin 0 -> 21316 bytes composer.json | 34 +++++++++++++++ phpunit.xml | 24 +++++++++++ readme.md | 7 ++++ src/OspekBackend.php | 84 +++++++++++++++++++++++++++++++++++++ src/OspekFrontend.php | 38 +++++++++++++++++ tests/OspekBackendTest.php | 52 +++++++++++++++++++++++ tests/loop.php | 10 +++++ 12 files changed, 337 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 LICENSE create mode 100644 appveyor.yml create mode 100644 asset/icon.png create mode 100644 composer.json create mode 100644 phpunit.xml create mode 100644 readme.md create mode 100644 src/OspekBackend.php create mode 100644 src/OspekFrontend.php create mode 100644 tests/OspekBackendTest.php create mode 100644 tests/loop.php diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ff631b0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +/.idea +/process.log +/phpcs-report.txt +/composer.lock +/vendor diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..67387a9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,25 @@ +language: php + +php: + - 7.0 + - 7.1 + - 7.2 + - master + +sudo: false + +before_install: + - composer self-update + - composer clear-cache + +install: + - travis_retry composer update --no-interaction --no-ansi --no-progress --no-suggest --optimize-autoloader --prefer-stable + +script: + - ./vendor/bin/phpunit --debug + +after_success: + - echo "success!" + +notifications: + email: false diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3900804 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 OSPEK + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..aaec099 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,37 @@ +build: false +shallow_clone: false +platform: 'x86' +clone_folder: C:\projects\ospek +branches: + only: + - windows + +install: + - cinst -y OpenSSL.Light + - SET PATH=C:\Program Files\OpenSSL;%PATH% + - sc config wuauserv start= auto + - net start wuauserv + - cinst -y php + - cd c:\tools\php72 + - copy php.ini-production php.ini + - echo date.timezone="UTC" >> php.ini + - echo extension_dir=ext >> php.ini + - echo extension=php_openssl.dll >> php.ini + - echo mbstring.http_input=pass >> php.ini + - echo mbstring.http_output=pass >> php.ini + - echo sendmail_path=nul >> php.ini + - echo extension=php_mbstring.dll >> php.ini + - echo extension=php_curl.dll >> php.ini + - echo extension=php_pdo_mysql.dll >> php.ini + - echo extension=php_pdo_pgsql.dll >> php.ini + - echo extension=php_pdo_sqlite.dll >> php.ini + - echo extension=php_pgsql.dll >> php.ini + - echo extension=php_gd2.dll >> php.ini + - cd C:\projects\ospek + - SET PATH=C:\tools\php72;%PATH% + - php -r "readfile('http://getcomposer.org/installer');" | php + - php composer.phar install --prefer-source --no-interaction + +test_script: + - cd C:\projects\ospek + - vendor\bin\phpunit.bat --debug \ No newline at end of file diff --git a/asset/icon.png b/asset/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..1b81d5ca124906a125d3a8548a2a02835091b261 GIT binary patch literal 21316 zcmW(*Wk8ef*M2rO*vK)YL0UQ_1QFOM>5`U|6jAv}NW(}eVRT4LML_9NnjtEPAV>=W zQ$SL>VeH-i{j`1Av-{l7b*^)+>zqVWV;wqb4r%}Z==5~8?f?LY{1pViD9Io8z7-w- zU{0f_rEU>4^Di7;$gSOc*&65}Yw-T-?V~|}@1BV%BOkAN&p&u<_pk#GNUNkl8~R(c zK;6wc@!^(ii}bc?^p3q*@0NKMgq^0P$|RN3QJr7D!uH!2=vpv|W7)O&!ixsBq2oKHZ|NWBR zHqZcabV~T}x7ti_KQ}3Y1A*pCN1&OO^z@i)kivH<$D>7pA@vUjpqi5!%>xLKh3RC3 z>%mv(gLmhc5+3b@yAO+jhdt7x(1t+^{XtS9VQ)A?$s1wVe&t)oYm2)#mOuW}w9?4# zM}U?@ymM0?!0}xem5`9fEZ|&WOv+tSv^=B0o4vFQnZi~Hq5W%#y)%GZeQnkH`Z>ehl z_0yRQhSz;dw)5LA;pT6A7=(!JH<)~FbR^=MM;hqapG-(Pw@mq4g3eX5 zyFP?l#>05uR9&`t{*eY#Uq&mkN^kmogW+<3uHw9n-m<}?@67_@WA8kLIzjCI-EALl z<=$rnn*cBUu@e85eyI^N{%Oil)02-R;eI%EyU3{cDzvMknKdq*hfeM&s)O`QNQQuorxkCD-`q9QGLe`3Zr|O)6^tVBe_T`aV zQ;kmto9+`v-W;SWn^)p0U2pP1B0Ui5z;7>hQ+}JKMX43$*)(!$AVzm5fRl)1p1f1& zzt!-uszuci#pbJvrB|B{4=CrJKHjDJ6LJ*diSuZFOf7Rg6I&JeP(@=TP+@H%GY*^y?Co0}njBNk*wn9xD%yyfrNHMN|DG$A;wC1{5R0hCY~@+IQV zzCObz{1is)U$SlF6i4@L++s4%FAn`sEreg-U}0qW&ax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*uxxqfdfAnIs>Kk z1Pp;4dI5$9>--}Exy+kSMgX?ne--omgUS+5wM!OGIyU8}^$twq708#_3rPnd85x8} z55%2-vh@TEB^V2kEvS(Jp6|!&)&S_%8epdYbMyV@%B&Re3?^~yrfXWZ?fQVM)&t_I{s=tZjmW&L{0DnL;SYBC0p`RYH-v(1}$2BWxGsAF0lU#`sx z!K_vWV$ZRehFn(zhQdq@@`q@iUgy}O(qpp+fXLy;+4_IPbFCEd3>I;{RM)obw0i`| z0G(!U0NpuuRAfH@R=ABp!gE1z&Bv+c;&sz^vXOiK{&+B2?*L@@Oe;Y=gH2ol(YAaY zcrpF}su>L1-GO9|N|BC=?+7Fl#eRVNZ<*UGA7<*fBf7`5+liS-C5UG*iwhv8DHjV~ znGTUIA!sG}0Fw8X$d|>wfVsYWk{y9DVLGzF++$iIF_lUX&tMf7K(sAaRK5=7.0.0", + "jolicode/jolinotif": "^2.0" + }, + "minimum-stability": "dev", + "autoload": { + "psr-4": { + "Ospek\\": "src/" + } + }, + "require-dev": { + "phpunit/phpunit": "^7.1@dev|~6.0" + } +} diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..af9c7eb --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,24 @@ + + + + tests + + + + + + + + + + src + + + \ No newline at end of file diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..25735ca --- /dev/null +++ b/readme.md @@ -0,0 +1,7 @@ +[![Build Status](https://travis-ci.org/os-pek/ospek.svg?branch=master)](https://travis-ci.org/os-pek/ospek) + + **Inspired :** + +- [dell_petter ](http://php.net/manual/en/function.exec.php#88704) + +- [composer-client](https://github.com/contao-community-alliance/composer-client) diff --git a/src/OspekBackend.php b/src/OspekBackend.php new file mode 100644 index 0000000..a118570 --- /dev/null +++ b/src/OspekBackend.php @@ -0,0 +1,84 @@ +_command = $cl; + if ($log != null) { + $this->_logFile = $log; + } else { + $this->_logFile = defined('PHP_WINDOWS_VERSION_BUILD')?"NUL":"/dev/null"; + } + $this->_run(); + } + } + private function _run() + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $command = $this->_command.' > '.$this->_logFile; + exec("start /B ".$command." 2>&1"); + } else { + + $command = $this->_command.' > '.$this->_logFile.' 2>&1 & echo $!'; + exec($command, $op); + $this->pid = (int)$op[0]; + } + } + + public function setPid(int $pid) + { + $this->pid = $pid; + } + + public function getPid():int + { + return $this->pid; + } + + public function status():bool + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + $process = shell_exec(sprintf('tasklist.exe /FI "PID eq %d" /FO CSV /NH', $this->pid)); + + return in_array($this->pid, str_getcsv($process, ',')); + } + + return (bool) posix_kill($this->pid, 0); + } + + public function start() + { + if ($this->_command !=null) { + $this->_run(); + } + throw new \LengthException("command is empty!"); + } + + public function stop():bool + { + if (defined('PHP_WINDOWS_VERSION_BUILD')) { + shell_exec(sprintf('taskkill.exe /PID %d', $this->pid)); + return true; + + } else { + + posix_kill($this->pid, SIGTERM); + return true; + } + } + public function getOutput(String $file=null):Array + { + $file = ($file)?$file:$this->_logFile; + if (file_exists($file)) { + return file($file); + } + throw new \RunTimeException("file not found!"); + } +} \ No newline at end of file diff --git a/src/OspekFrontend.php b/src/OspekFrontend.php new file mode 100644 index 0000000..3146b62 --- /dev/null +++ b/src/OspekFrontend.php @@ -0,0 +1,38 @@ +pid = getmypid(); + $this->_notif = ($notif)?true:false; + $this->_joliNotifier = ($notif)?NotifierFactory:: create():false; + } + private function _defaultNotif() + { + $notification = (new Notification())->setTitle('OSPEK')->setBody("process ".$this->pid." has been stopped!")->setIcon(__DIR__ . '/../asset/icon.png')->addOption('sound', 'Frog'); + $this->_joliNotifier->send($notification); + } + public function setNotif(callable $fun) + { + $this->_fun = $fun; + } + + public function __destruct() + { + if ($this->_notif) { + if ($this->_fun!=null) { + ($this->_fun)($this->_joliNotifier, new Notification()); + } else { + $this->_defaultNotif(); + } + } + } +} \ No newline at end of file diff --git a/tests/OspekBackendTest.php b/tests/OspekBackendTest.php new file mode 100644 index 0000000..2dc21aa --- /dev/null +++ b/tests/OspekBackendTest.php @@ -0,0 +1,52 @@ +_ospek = null; + } + + public function testOspekRun() + { + $this->_ospek = new \Ospek\OspekBackend("php tests/loop.php", "process.log"); + sleep(3); + // test getpid() + $this->assertInternalType('int', $this->_ospek->getPid()); + + // test status() + $this->assertTrue($this->_ospek->status()); + + // test getOutput() + $this->assertInternalType('array', $this->_ospek->getOutput()); + + // test stop() + $this->assertTrue($this->_ospek->stop()); + sleep(1); + + // check status after stop + $this->assertFalse($this->_ospek->status()); + // make sure process.log not empty + + $this->assertNotEmpty(file_get_contents("process.log")); + + } + public function testOspekDummy() + { + $this->_ospek = new \Ospek\OspekBackend(); + $this->assertNull($this->_ospek->setPid(1234567)); + $this->assertSame(1234567, $this->_ospek->getPid()); + $this->assertFalse($this->_ospek->status()); + try{ + $this->_ospek->getOutput('fakeeeeeeee/path/file.log'); + } catch(Exception $e){ + $this->assertInstanceOf(RuntimeException::class, $e); + } + + + + } +} + \ No newline at end of file diff --git a/tests/loop.php b/tests/loop.php new file mode 100644 index 0000000..aab210a --- /dev/null +++ b/tests/loop.php @@ -0,0 +1,10 @@ +