-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1d3e4f1
commit 37c779c
Showing
4 changed files
with
73 additions
and
65 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,14 +1,24 @@ | ||
# Omniscient | ||
|
||
[![Terminus v1.x Compatible](https://img.shields.io/badge/terminus-v1.x-green.svg)](https://github.com/terminus-plugin-project/terminus-omniscient/tree/1.x) | ||
[![Terminus v0.x Compatible](https://img.shields.io/badge/terminus-v0.x-green.svg)](https://github.com/terminus-plugin-project/terminus-omniscient/tree/0.x) | ||
|
||
Terminus Plugin to enable [New Relic Pro](https://pantheon.io/docs/new-relic/) on all [Pantheon](https://www.pantheon.io) sites. | ||
|
||
Adds a sub-command to 'sites' which is called 'omniscient'. This enables New Relic Pro for all sites your account has access to. | ||
|
||
## Examples | ||
* `terminus sites omniscient` | ||
* `terminus omniscient` | ||
|
||
## Installation | ||
For help installing, see [Terminus's Wiki](https://github.com/pantheon-systems/terminus/wiki/Plugins) | ||
To install this plugin place it in `~/.terminus/plugins/`. | ||
|
||
On Mac OS/Linux: | ||
``` | ||
mkdir -p ~/.terminus/plugins | ||
composer create-project -d ~/.terminus/plugins terminus-plugin-project/terminus-omniscient:~1 | ||
``` | ||
For additional help installing, see [Terminus' Plugins](https://pantheon.io/docs/terminus/plugins/). | ||
|
||
## Help | ||
Run `terminus help sites omniscient` for help. | ||
Run `terminus help omniscient` for help. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace rvtraveller\Omniscient\Commands; | ||
|
||
use Pantheon\Terminus\Commands\TerminusCommand; | ||
use Pantheon\Terminus\Site\SiteAwareInterface; | ||
use Pantheon\Terminus\Site\SiteAwareTrait; | ||
|
||
class OmniscientCommand extends TerminusCommand implements SiteAwareInterface | ||
{ | ||
use SiteAwareTrait; | ||
|
||
/** | ||
* Enables New Relic Pro on all sites/environments a user has access | ||
* to. | ||
* | ||
* @authorize | ||
* | ||
* @command sites:omniscient | ||
* @alias omniscient | ||
* | ||
* @usage terminus sites:omniscient | ||
*/ | ||
public function omniscient() { | ||
$this->sites()->fetch(); | ||
|
||
$sites = $this->sites()->serialize(); | ||
|
||
foreach ($sites as $site) { | ||
$site = $this->getSite($site['name']); | ||
$site_name = $site->getName(); | ||
$new_relic_info = $site->getNewRelic(); | ||
$new_relic_info->fetch(); | ||
$new_relic_data = $new_relic_info->serialize(); | ||
if (empty($new_relic_data)) { | ||
// New Relic is disabled. | ||
if ((boolean)$site->get('frozen')) { | ||
$this->log()->notice("Skipping $site_name because site is frozen."); | ||
} | ||
else { | ||
$new_relic_info->enable(); | ||
$this->log()->notice("Enabled New Relic Pro for $site_name"); | ||
} | ||
} | ||
else { | ||
$this->log()->notice("Skipping $site_name because New Relic Pro is already enabled."); | ||
} | ||
} | ||
} | ||
|
||
} |