Permalink
Browse files

Readapt BoosterManager to new config file format

  • Loading branch information...
1 parent e557517 commit 8fcaf96602c102ea37174f52336ef6b10d8aefc0 @cdujeu cdujeu committed Aug 29, 2016
Showing with 35 additions and 6 deletions.
  1. +35 −6 core/src/plugins/core.mq/src/Booster/BoosterManager.php
@@ -42,7 +42,8 @@ class BoosterManager
private $pluginWorkDir;
private $pluginCacheDir;
- private $configFileName = "pydiocaddy";
+ private $configFileJson = "pydioconf";
+ private $configFileCaddy = "pydiocaddy";
private $logFileName = "pydio.out";
private $pidFileName = "caddy-pid";
@@ -113,6 +114,29 @@ public function tailLogs($offset = 0){
}
/**
+ * @param array $params
+ * @param string $adminKeyString
+ * @return array
+ */
+ public function generatePydioBoosterJson($params, $adminKeyString){
+
+ list($tokenP, $tokenS) = explode(":", $adminKeyString);
+ return [
+ "scheduler" => [
+ "host" => ApplicationState::detectServerURL(true),
+ "tokenP" => $tokenP,
+ "tokenS" => $tokenS,
+ "minutes" => 2
+ ],
+ "nsq" => [
+ "host" => "0.0.0.0",
+ "port" => intval($params["NSQ_PORT"])
+ ]
+ ];
+
+ }
+
+ /**
* @param $params
* @param string
* @return string
@@ -227,22 +251,27 @@ public function generatePydioBoosterFile($params, $adminKeyString) {
return $data;
}
+
+
/**
* @param array $params
* @param string $adminKeyString
* @return string
* @throws \Exception
*/
public function savePydioBoosterFile($params, $adminKeyString) {
- $data = $this->generatePydioBoosterFile($params, $adminKeyString);
$wDir = $this->pluginWorkDir;
- $caddyFile = $wDir.DIRECTORY_SEPARATOR.$this->configFileName;
-
- // Generate the caddyfile
+ $caddyFile = $wDir.DIRECTORY_SEPARATOR.$this->configFileCaddy;
+ $data = $this->generatePydioBoosterFile($params, $adminKeyString);
file_put_contents($caddyFile, $data);
- return $caddyFile;
+ $jsonFile = $wDir.DIRECTORY_SEPARATOR.$this->configFileJson;
+ $jsonData = $this->generatePydioBoosterJson($params, $adminKeyString);
+ $jsonData["caddyFilePath"] = $caddyFile;
+ file_put_contents($jsonFile, json_encode($jsonData, JSON_PRETTY_PRINT));
+
+ return $jsonFile;
}
/**

0 comments on commit 8fcaf96

Please sign in to comment.