Skip to content

New Relic: Disables Module Deployments, Creates new Deploy Marker Command #11204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions app/code/Magento/NewRelicReporting/Command/DeployMarker.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
namespace Magento\NewRelicReporting\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputArgument;

use Magento\NewRelicReporting\Model\Apm\DeploymentsFactory;
use Magento\NewRelicReporting\Model\ServiceShellUser;

class DeployMarker extends Command
{
protected $deploymentsFactory;
protected $serviceShellUser;
public function __construct(
DeploymentsFactory $deploymentsFactory,
ServiceShellUser $serviceShellUser,
$name = null
)
{
$this->deploymentsFactory = $deploymentsFactory;
$this->serviceShellUser = $serviceShellUser;
parent::__construct($name);
}

protected function configure()
{
$this->setName("newrelic:create:deploy-marker");
$this->setDescription("Check the deploy queue for entries and create an appropriate deploy marker.")
->addArgument(
'message',
InputArgument::REQUIRED,
'Deploy Message?')
->addArgument(
'changelog',
InputArgument::REQUIRED,
'Change Log?')
->addArgument(
'user',
InputArgument::OPTIONAL,
'Deployment User');
parent::configure();
}

protected function execute(InputInterface $input, OutputInterface $output)
{
$this->deploymentsFactory->create()->setDeployment(
$input->getArgument('message'),
$input->getArgument('changelog'),
$this->serviceShellUser->get($input->getArgument('user'))
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ protected function reportCounts()
public function report()
{
if ($this->config->isNewRelicEnabled()) {
$this->reportModules();
$this->reportCounts();
}

Expand Down
21 changes: 21 additions & 0 deletions app/code/Magento/NewRelicReporting/Model/ServiceShellUser.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
namespace Magento\NewRelicReporting\Model;
class ServiceShellUser
{
const DEFAULT_USER='cron';
public function get($userFromArgument=false)
{
if($userFromArgument)
{
return $userFromArgument;
}

$user = `echo \$USER`;
if($user)
{
return $user;
}

return self::DEFAULT_USER;
}
}
7 changes: 7 additions & 0 deletions app/code/Magento/NewRelicReporting/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,11 @@
</argument>
</arguments>
</type>
<type name="Magento\Framework\Console\CommandList">
<arguments>
<argument name="commands" xsi:type="array">
<item name="magento_new_relic_reporting_command_deploy_marker" xsi:type="object">Magento\NewRelicReporting\Command\DeployMarker</item>
</argument>
</arguments>
</type>
</config>