-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from silinternational/release/5.2.0
Release 5.2.0 -- new monitoring option
- Loading branch information
Showing
4 changed files
with
88 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Sil\Idp\IdSync\common\components; | ||
|
||
use GuzzleHttp\Client; | ||
use yii\base\Component; | ||
|
||
class Monitor extends Component | ||
{ | ||
/** | ||
* @var null|string the URL to request for a heartbeat check | ||
*/ | ||
public $heartbeatUrl = ''; | ||
|
||
/** | ||
* @var null|string the HTTP request method (verb) to use for a heartbeat check | ||
*/ | ||
public $heartbeatMethod = ''; | ||
|
||
public function Heartbeat() | ||
{ | ||
if (empty($this->heartbeatUrl)) { | ||
return; | ||
} | ||
|
||
$client = new Client(); | ||
|
||
$method = 'POST'; | ||
if (!empty($this->heartbeatMethod)) { | ||
$method = $this->heartbeatMethod; | ||
} | ||
|
||
try { | ||
$client->request($method, $this->heartbeatUrl); | ||
} catch (\Throwable $e) { | ||
\Yii::error('heartbeat error: ' . $e->getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters