/**
  * Parses a section array.
  *
  * @param array              $sections
  * @param Configuration|null $configuration
  *
  * @return Configuration
  */
 public function parseSections(array $sections, Configuration $configuration = null)
 {
     if (is_null($configuration)) {
         $configuration = new Configuration();
     }
     foreach ($sections as $sectionName => $section) {
         $name = explode(':', $sectionName, 2);
         $class = $configuration->findSection($name[0]);
         if (false === $class) {
             $class = 'Supervisor\\Configuration\\Section\\GenericSection';
             $name[1] = $sectionName;
         }
         if (isset($name[1])) {
             $section = new $class($name[1], $section);
         } else {
             $section = new $class($section);
         }
         $configuration->addSection($section);
     }
     return $configuration;
 }
Esempio n. 2
0
 /**
  * publishs the tracking of terms with supervisor and phirehose
  *
  * @return \Illuminate\View\View
  */
 public function publish($team, $network_id)
 {
     $team = Team::where('slug', '=', $team)->first();
     $network = Network::find($network_id);
     $network = $network->title;
     $keys = json_decode($team->{$network});
     //Create GuzzleHttp client
     $guzzleClient = new \GuzzleHttp\Client();
     // Pass the url and the guzzle client to the XmlRpc Client
     $client = new Client('http://localhost:9001/RPC2', new HttpAdapterTransport(new Guzzle6HttpAdapter($guzzleClient)));
     // Generate XMLRpc and Supervisor Instances
     $connector = new XmlRpc($client);
     $supervisor = new Supervisor($connector);
     // setup flysystem
     $adapter = new Local('/etc/supervisor/conf.d/');
     $filesystem = new Filesystem($adapter);
     // create new supervisor files
     $writer = new File($filesystem, 'test.conf');
     $configuration = new Configuration();
     $section = $this->generateNewProcess($keys, $team->id);
     $configuration->addSection($section);
     $writer->write($configuration);
     // restart supervisor
     $supervisor->restart();
 }