Sfoglia il codice sorgente

merge thurdata & 3.4.0

andre 4 anni fa
parent
commit
cb837a90c7

+ 48 - 0
app/Cron/QueueLoop.php

@@ -0,0 +1,48 @@
+<?php
+
+
+namespace ModulesGarden\ProxmoxAddon\App\Cron;
+
+
+use ModulesGarden\ProxmoxAddon\Core\CommandLine\CommandLoop;
+use ModulesGarden\ProxmoxAddon\Core\CommandLine\Hypervisor;
+use ModulesGarden\ProxmoxAddon\Core\Queue\Models\Job;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
+
+class QueueLoop extends  CommandLoop
+{
+
+    /**
+     * Command name
+     * @var string
+     */
+    protected $name = 'queue-loop';
+
+    /**
+     * Command description
+     * @var string
+     */
+    protected $description = 'Run module queue loop';
+
+    /**
+     * Command help text
+     * @var string
+     */
+    protected $help = 'Just run that command to start all queued tasks!';
+
+    protected function process(InputInterface $input, OutputInterface $output, SymfonyStyle $io)
+    {
+        $queue = new \ModulesGarden\ProxmoxAddon\Core\Queue\Queue();
+        $queue->setCallBefore(function (Job $job) use ($input,$io)
+        {
+            $io->writeln("Running {$job->job}");
+            (new Hypervisor($this->getName(), $input->getOptions()))
+                ->ping();
+        });
+        $queue->process();
+    }
+
+
+}

+ 130 - 0
app/Cron/Snapshots.php

@@ -0,0 +1,130 @@
+<?php
+
+
+namespace ModulesGarden\ProxmoxAddon\App\Cron;
+
+
+use ModulesGarden\ProxmoxAddon\App\Jobs\Vps\SnapshotVmJob;
+use ModulesGarden\ProxmoxAddon\App\Models\Job;
+use ModulesGarden\ProxmoxAddon\App\Models\ProductConfiguration;
+use ModulesGarden\ProxmoxAddon\App\Models\SnapshotJob;
+use ModulesGarden\ProxmoxAddon\App\Models\Whmcs\Hosting;
+use ModulesGarden\ProxmoxAddon\App\Services\ApiService;
+use ModulesGarden\ProxmoxAddon\App\Services\Vps\ProductService;
+use ModulesGarden\ProxmoxAddon\Core\CommandLine\Command;
+use ModulesGarden\ProxmoxAddon\Core\UI\Traits\WhmcsParams;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Style\SymfonyStyle;
+use function ModulesGarden\ProxmoxAddon\Core\Helper\queue;
+
+class Snapshots extends Command
+{
+    use WhmcsParams;
+    use ProductService;
+    use ApiService;
+
+    /**
+     * Command name
+     * @var string
+     */
+    protected $name = 'snapshots';
+
+    /**
+     * Command description
+     * @var string
+     */
+    protected $description = 'Snapshots schedule';
+
+    /**
+     * Command help text
+     * @var string
+     */
+    protected $help = '';
+
+    /**
+     * @param InputInterface $input
+     * @param OutputInterface $output
+     * @param SymfonyStyle $io
+     * @throws \Exception
+     * @query daily SELECT *, DATE(`updated_at`) as t FROM `ProxmoxAddon_SnapshotJob` where `period` = 'daily' and TIMESTAMP(`start_time`) < TIMESTAMP(NOW()) and TIMESTAMP(updated_at) < TIMESTAMP(`start_time`) or ( `period` = 'daily' AND `start_time` is NULL AND DATE(`updated_at`) != DATE(NOW()) )
+     * @query hourly SELECT *, DATE(`updated_at`) as t FROM `ProxmoxAddon_SnapshotJob` where `period` = 'hourly' and TIMESTAMP(NOW()) >= TIMESTAMP( DATE_ADD(updated_at, INTERVAL `run_every` HOUR ))
+     */
+    protected function process(InputInterface $input, OutputInterface $output, SymfonyStyle $io)
+    {
+        $io->title('Snapshots schedule: Starting');
+        $productIds = ProductConfiguration::ofSetting('permissionSnapshotJob')
+            ->where("value", "not like", '\"\"')
+            ->pluck("product_id")
+            ->all();
+        if (empty($productIds))
+        {
+            $io->error("Scheduled Snapshot Jobs is not configured");
+            return;
+        }
+        $h        = (new Hosting())->getTable();
+        $sj =  (new SnapshotJob())->getTable();
+        $entities = SnapshotJob::select("{$sj}.*")
+            ->leftJoin($h, "{$h}.id", '=', "{$sj}.hosting_id")
+            ->whereRaw("{$sj}.period = 'daily' 
+                        AND TIMESTAMP({$sj}.start_time) < TIMESTAMP(NOW()) 
+                        AND TIMESTAMP({$sj}.updated_at) < TIMESTAMP({$sj}.start_time)
+                        OR ( {$sj}.period = 'daily' 
+                             AND {$sj}.start_time IS NULL 
+                             AND DATE({$sj}.updated_at) != DATE(NOW()) 
+                             )
+                        OR (
+                            {$sj}.period = 'hourly' 
+                            AND  TIMESTAMP(NOW()) >= TIMESTAMP( DATE_ADD({$sj}.updated_at, INTERVAL {$sj}.run_every HOUR ))
+                            )
+                        ")
+            ->where("{$h}.domainstatus", "Active")
+            ->whereIn("{$h}.packageid", $productIds);
+        $i        = 0;
+        /**
+         * DAYName(NOW())        Friday
+         * @var  SnapshotJob $entity
+         */
+        foreach ($entities->get() as $entity)
+        {
+
+            try
+            {
+                $now = new \DateTime();
+                $today = $now->format("l");
+                if($entity->period == "daily" && ( $entity->days && !in_array($today, $entity->days) ) ){
+                    continue;
+                }
+                $i++;
+                $output->writeln(sprintf("Synchronize snapshot job #%s (Hosting ID %s)",$entity->id, $entity->hosting_id));
+                //cloud
+                if($entity->vm_id){
+                    $jobClass = \ModulesGarden\ProxmoxAddon\App\Jobs\Cloud\SnapshotVmJob::class;
+                }else{//vps
+                    $jobClass = SnapshotVmJob::class;
+                }
+                $query = Job::waiting()
+                             ->ofHostingId($entity->hosting_id)
+                            ->ofJob($jobClass);
+                if($entity->vm_id){
+                    $query->ofCustomId($entity->vm_id);
+                }
+                if(!$query->count()){
+                    $job=["snapshotJobId"=> $entity->id];
+                    queue($jobClass, $job, null, "hosting", $entity->hosting_id, $entity->vm_id);
+                    $entity->update(['updated_at' => date("Y-m-d H:i:s")]);
+                    $output->writeln(sprintf("Snapshot job #%s has been synchronized", $entity->id));
+                }
+            }catch (\Exception $ex)
+            {
+                $io->error( $ex->getMessage());
+            }
+        }
+        $output->writeln("");
+        $io->success([
+            sprintf("Synchronize snapshots schedule: %s Entries Processed.", $i),
+            "Snapshots schedule: Done"
+        ]);
+    }
+
+}

+ 29 - 24
app/Jobs/Cloud/SnapshotVmJob.php

@@ -1,4 +1,6 @@
 <?php
+
+
 namespace ModulesGarden\ProxmoxAddon\App\Jobs\Cloud;
 
 
@@ -11,8 +13,8 @@ use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ProductService;
 use ModulesGarden\ProxmoxAddon\App\Enum\Cloud\ConfigurableOption;
 use function ModulesGarden\ProxmoxAddon\Core\Helper\sl;
 
-
-class SnapshotVmJob extends BaseJob {
+class SnapshotVmJob extends BaseJob
+{
 
     use ProductService;
 
@@ -21,15 +23,18 @@ class SnapshotVmJob extends BaseJob {
      */
     private  $snapshotJob;
 
-    public function handle($text = null)  {
+    public function handle($text = null)
+    {
         openlog("ProxmoxSnapshot", LOG_PID, LOG_SYSLOG);
-
         $this->initParams();
         $this->setHostingId($this->getWhmcsParamByKey("serviceid"));
         $this->initVm();
-        if ($this->isDone()) {
+        if ($this->isDone())
+        {
             return true;
-        } elseif ($this->isTaskRunning()) {
+        }
+        elseif ($this->isTaskRunning())
+        {
             //sleep
             $this->sleep(5);
             return false;
@@ -38,27 +43,26 @@ class SnapshotVmJob extends BaseJob {
         $snapshot->setApi($this->api());
         $snapshot->setPath(sl('Vm')->getVm()->getPath() . "/snapshot");
         $snapshot->setAttributes([
+            // "name"        => $this->getSnapshotJob()->name."_".$this->model->id,
             // Changed by Roland at 2021-08-28 because duplicate snappshot names which causes the error: TASK ERROR: snapshot name 'Secure_280' already used
             // Added ' "_" . date("m") . "_" . date("d") . "_" . date("H"),' to make the snapshot-name more unique
             "name"        => $this->getSnapshotJob()->name . "_" . $this->model->id . "_" . date("m") . "_" . date("d") . "_" . date("H"),
             "description" => $this->snapshotJob->description,
         ]);
-        
-        syslog(LOG_NOTICE,"Creating Snapshot for " . $this->getSnapshotJob()->name . "_" . $this->model->id . date("d") . "_" . date("H"));
-        if (!is_null($this->snapshotJob->vmstate ) && sl('Vm')->getVm() instanceof  Kvm) {
+        syslog(LOG_NOTICE,"Creating Snapshot for " . $this->getSnapshotJob()->name . "_" . $this->model->id . date("m") . "_" . date("d") . "_" . date("H"));
+        if (!is_null($this->snapshotJob->vmstate ) && sl('Vm')->getVm() instanceof  Kvm)
+        {
             $snapshot->setVmstate($this->snapshotJob->vmstate );
         }
         $taskId =  $snapshot->create();
         //save task id
         $this->putModelDataAndSave(["taskId" => $taskId, "node" => sl('Vm')->getVm()->getNode()]);
-        
         //sleep
         $this->sleep(5);
         $this->clean();
         $this->sleep(25);
         return false;
     }
-    
 
     /**
      * @return SnapshotJob
@@ -97,22 +101,23 @@ class SnapshotVmJob extends BaseJob {
             while(!empty($errorMessage) && $errorCount < 18) {
                 syslog(LOG_NOTICE,"   ->Delete Snapshot: " . $entity->getName() );
                 while(!empty($errorMessage) && $errorCount < 18) {
-                try {
-                    $result = $entity->delete();
-                    //syslog(LOG_NOTICE,"   ->RESULT " . print_r($result,true) );
+                    try {
+                        $result = $entity->delete();
+                        //syslog(LOG_NOTICE,"   ->RESULT " . print_r($result,true) );
 
-                    $errorMessage = "";
-                    syslog(LOG_NOTICE,"   ->SUCCESS " . $result );
-                    sleep(55);
-                } catch(\Exception $ex) {
-                    $errorMessage = $ex->getMessage();
-                    syslog(LOG_NOTICE,"   ->ERROR " . $errorCount . ": " . $errorMessage );
-                    $errorCount ++;
-                    sleep(55);
+                        $errorMessage = "";
+                        syslog(LOG_NOTICE,"   ->SUCCESS " . $result );
+                        sleep(55);
+                    } catch(\Exception $ex) {
+                        $errorMessage = $ex->getMessage();
+                        syslog(LOG_NOTICE,"   ->ERROR " . $errorCount . ": " . $errorMessage );
+                        $errorCount ++;
+                        sleep(55);
+                    }
                 }
-            }
             $toDelete --;
+            }
         }
-    }
     syslog(LOG_NOTICE,"Snapshot Clean DONE" );
+    }
 }

+ 50 - 24
app/Jobs/Vps/BaseJob.php

@@ -63,7 +63,8 @@ class BaseJob extends Job
      */
     protected $additionalMountPointService;
 
-    protected function initServices()  {
+    protected function initServices()
+    {
         $this->emailService     = new EmailService();
         $this->containerService = new ContainerService();
         $this->agentService = new AgentService();
@@ -72,7 +73,8 @@ class BaseJob extends Job
 
     }
 
-    public function initParams()  {
+    public function initParams()
+    {
         if (!$this->model->rel_id)
         {
             new \InvalidArgumentException(sprintf("Job model: #%s rel_id cannot be empty", $this->model->id));
@@ -88,13 +90,15 @@ class BaseJob extends Job
         return $this;
     }
 
-    protected function sleep($seconds = 60)  {
+    protected function sleep($seconds = 60)
+    {
         $this->model->setWaiting();
         $this->model->setRetryAfter(date("Y-m-d H:i:s", strtotime("+{$seconds} seconds")));
         $this->model->increaseRetryCount();
     }
 
-    protected function vmidExistInWhmcs($vmid)  {
+    protected function vmidExistInWhmcs($vmid)
+    {
         //vps
         $cfv   = 'tblcustomfieldsvalues';
         $cfn   = 'tblcustomfields';
@@ -105,7 +109,8 @@ class BaseJob extends Job
             ->where("{$cfn}.fieldname", "like", "vmid%")
             ->where("{$cfv}.value", $vmid)
             ->whereIn("{$h}.domainstatus", ['Active', "Suspended"]);
-        if ($query->count())  {
+        if ($query->count())
+        {
             return true;
         }
         //cloud
@@ -120,31 +125,41 @@ class BaseJob extends Job
         return false;
     }
 
-    protected function findFreeVmid($vmid)  {
-        for ($i = $vmid; $i <= 1000000; $i++) {
-            if ($this->vmidExistInWhmcs($i)) {
+    protected function findFreeVmid($vmid)
+    {
+        for ($i = $vmid; $i <= 1000000; $i++)
+        {
+            if ($this->vmidExistInWhmcs($i))
+            {
                 continue;
             }
-            try  {
+            try
+            {
                 $res = $this->api()->get("/cluster/nextid", ['vmid' => $i]);
-            } catch (\Exception $ex) {
+            }
+            catch (\Exception $ex)
+            {
                 continue;
             }
-            if ($res == $i) {
+            if ($res == $i)
+            {
                 return $i;
             }
         }
         throw new \Exception("Unable to obtain vmid");
     }
 
-    protected function isVmRange(){
-        if (RangeVm::ofServerId($this->getWhmcsParamByKey("serverid"))->count()) {
+    protected function isVmRange()
+    {
+        if (RangeVm::ofServerId($this->getWhmcsParamByKey("serverid"))->count())
+        {
             return true;
         }
         return Configuration::where("setting", "proxmoxVPSMinimumVMID")->count() > 0;
     }
 
-    protected function nextVmid() {
+    protected function nextVmid()
+    {
         $data = $this->api()->get("/cluster/nextid", []);
         $vmid = (int)$data ? (int)$data : 100;
         $vmid = $this->findFreeVmid($vmid);
@@ -157,7 +172,9 @@ class BaseJob extends Job
             if (!$rageVm->has() && !$rageVm->getMin())
             {
                 return $vmid;
-            } else  {
+            }
+            else
+            {
                 if (!$rageVm->getMax() && $rageVm->getMin())
                 {
                     $from = (int)$rageVm->getMin();
@@ -291,18 +308,23 @@ class BaseJob extends Job
         return $task->getExitstatus() && $task->getExitstatus() != "OK";
     }
 
-    protected function failed($error) {
+    protected function failed($error)
+    {
 
-        if ((int)$this->model->retry_count != 21) {
+        if ((int)$this->model->retry_count != 21)
+        {
             return;
         }
-        if (!preg_match("/Create/", $this->model->job) || preg_match("/Clone/", $this->model->job)) {
+        if (!preg_match("/Create/", $this->model->job) || preg_match("/Clone/", $this->model->job))
+        {
             return;
         }
         //create new entery on to do list
-        if ($this->configuration()->isToDoList())  {
+        if ($this->configuration()->isToDoList())
+        {
             $title = sprintf('Creation Failed - Service ID: %s', $this->getWhmcsParamByKey('serviceid'));
-            if (ToDoList::ofTitle($title)->pending()->count())  {
+            if (ToDoList::ofTitle($title)->pending()->count())
+            {
                 return;
             }
             $entity = new ToDoList();
@@ -350,17 +372,21 @@ class BaseJob extends Job
     /**
      * @return \ModulesGarden\ProxmoxAddon\App\Models\Job:
      */
-    protected function getParentModel() {
-        if (is_null($this->model->parent_id)) {
+    protected function getParentModel()
+    {
+        if (is_null($this->model->parent_id))
+        {
             throw new \InvalidArgumentException("The Parent Id is not valid");
         }
-        if ($this->parent) {
+        if ($this->parent)
+        {
             return $this->parent;
         }
         return $this->parent = \ModulesGarden\ProxmoxAddon\App\Models\Job::ofId($this->model->parent_id)->firstOrFail();
     }
 
-    protected function getParentModelData() {
+    protected function getParentModelData()
+    {
         return unserialize($this->getParentModel()->data);
     }
 

+ 19 - 17
app/Jobs/Vps/SnapshotVmJob.php

@@ -1,6 +1,9 @@
 <?php
+
+
 namespace ModulesGarden\ProxmoxAddon\App\Jobs\Vps;
 
+
 use MGProvision\Proxmox\v2\models\Kvm;
 use MGProvision\Proxmox\v2\models\Snapshot;
 use MGProvision\Proxmox\v2\repository\SnapshotRepository;
@@ -8,7 +11,8 @@ use ModulesGarden\ProxmoxAddon\App\Models\SnapshotJob;
 use ModulesGarden\ProxmoxAddon\App\Services\Vps\ProductService;
 use ModulesGarden\ProxmoxAddon\App\Enum\Vps\ConfigurableOption;
 
-class SnapshotVmJob extends BaseJob {
+class SnapshotVmJob extends BaseJob
+{
 
     use ProductService;
 
@@ -17,54 +21,53 @@ class SnapshotVmJob extends BaseJob {
      */
     private  $snapshotJob;
 
-    public function handle($text = null)  {
+    public function handle($text = null)
+    {
         openlog("ProxmoxSnapshot", LOG_PID,LOG_SYSLOG);
         $this->initParams();
         $this->setHostingId($this->getWhmcsParamByKey("serviceid"));
-        if ($this->isDone()) {
+        if ($this->isDone())
+        {
             return true;
-        } elseif ($this->isTaskRunning())  {
+        }
+        elseif ($this->isTaskRunning())
+        {
             //sleep
             $this->sleep(25);
             return false;
         }
-        
         syslog(LOG_NOTICE,"Snapshot Create for " . $this->model->id );
         $snapshot = new Snapshot();
         $snapshot->setApi($this->api());
         $snapshot->setPath($this->vm()->getPath() . "/snapshot");
         $snapshot->setAttributes([
-    	    // Changed by Roland at 2021-08-28 because duplicate snappshot names which causes the error: TASK ERROR: snapshot name 'Secure_280' already used
-    	    // Added ' "_" . date("m") . "_" . date("d") . "_" . date("H") . "_" . date("i"),' to make the snapshot-name more unique
             "name"        => $this->getSnapshotJob()->name . "_" . date("m") . "_" . date("d") . "_" . date("H") . "_" . date("i"),
             "description" => $this->snapshotJob->description,
         ]);
         syslog(LOG_NOTICE,"   Creating Snapshot for " . $this->getSnapshotJob()->name . "_" . $this->model->id . "_" . date("m") . "_" . date("d") . "_" . date("H"));
-        if (!is_null($this->snapshotJob->vmstate ) && $this->vm() instanceof  Kvm) {
+        if (!is_null($this->snapshotJob->vmstate ) && $this->vm() instanceof  Kvm)
+        {
             $snapshot->setVmstate($this->snapshotJob->vmstate );
         }
-        
         try {
     	    $taskId =  $snapshot->create();
         } catch(\Exception $ex) {
     	    $message = $ex->getMessage();
     	    syslog(LOG_NOTICE,"!!Snapshot throw Exception: " . $message );
-	    if (strpos($message,"snapshot") === false && strpos($message,"already") === false && strpos($message,"used") === false ) {
+    	    if (strpos($message,"snapshot") === false && strpos($message,"already") === false && strpos($message,"used") === false ) {
     	        throw $ex;
     	    }
         }
-        sleep(25);
+        $this->sleep(25);
         $this->clean();
-	$this->sleep(5);
-	
+        $this->sleep(5);
         //save task id
         $this->putModelDataAndSave(["taskId" => $taskId, "node" => $this->vm()->getNode()]);
-        
+        //sleep
         syslog(LOG_NOTICE,"Snapshot Processing DONE" );
         return false;
     }
 
-
     /**
      * @return SnapshotJob
      */
@@ -72,7 +75,7 @@ class SnapshotVmJob extends BaseJob {
         return $this->snapshotJob = SnapshotJob::findOrFail($this->getModelData()['snapshotJobId']);
     }
 
-    private function clean() {
+    private function clean(){
         syslog(LOG_NOTICE,"Snapshot Clean for " . $this->model->id );
         $limit = $this->getWhmcsConfigOption(ConfigurableOption::SNAPSHOTS, $this->configuration()->getSnapshotMaxFiles());
         syslog(LOG_NOTICE,"   Checking Snapshot Limit (" . $limit . ") for " . $this->model->id );
@@ -92,7 +95,6 @@ class SnapshotVmJob extends BaseJob {
         $toDelete = (int) $snapshotRepository->count() - $limit;
         syslog(LOG_NOTICE,"   Snapshots: Existing: " . $snapshotRepository->count() . "   Limit: " . $limit );
         syslog(LOG_NOTICE,"   Number of Snapshots to delete: " . $toDelete );
-        
         foreach ($snapshotRepository->sortBySnaptime()->fetch() as $entity) {
     	    syslog(LOG_NOTICE,"   Checking Snapshot: " . $entity->getName() . " (" . $entity->getPath() . ")" );
             if($toDelete <=0){

+ 4 - 2
app/Models/Job.php

@@ -23,8 +23,10 @@ class Job extends \ModulesGarden\ProxmoxAddon\Core\Queue\Models\Job
         return $query->where("job", $job . '@handle');
     }
 
-    public function scopeOfJobs($query, $jobs)  {
-        foreach ($jobs as &$job) {
+    public function scopeOfJobs($query, $jobs)
+    {
+        foreach ($jobs as &$job)
+        {
             $job .= '@handle';
         }
         return $query->whereIn("job", $jobs);

+ 4 - 2
app/Models/SnapshotJob.php

@@ -21,7 +21,8 @@ use ModulesGarden\ProxmoxAddon\Core\Models\ExtendedEloquentModel;
  * @property string $created_at
  * @method static $this ofHostingId($hostingId)
  */
-class SnapshotJob extends ExtendedEloquentModel {
+class SnapshotJob extends ExtendedEloquentModel
+{
 
     /** @var string */
     protected $table = 'SnapshotJob';
@@ -36,7 +37,8 @@ class SnapshotJob extends ExtendedEloquentModel {
         'days' => 'array',
     ];
 
-    public function scopeOfHostingId($query, $hostingId) {
+    public function scopeOfHostingId($query, $hostingId)
+    {
         return $query->where("hosting_id", $hostingId);
     }
 

+ 1 - 1
app/Services/Cloud/ClientAreaSidebarService.php

@@ -170,4 +170,4 @@ class ClientAreaSidebarService
 
         }
     }
-}
+}

+ 2 - 1
app/Services/Vm.php

@@ -8,7 +8,8 @@ use MGProvision\Proxmox\v2\models\Kvm;
 use MGProvision\Proxmox\v2\models\Lxc;
 use ModulesGarden\ProxmoxAddon\App\Models\VmModel;
 
-class Vm {
+class Vm
+{
     /**
      * @var Kvm|Lxc
      */

+ 1 - 0
core/CommandLine/Application.php

@@ -52,6 +52,7 @@ class Application extends \Symfony\Component\Console\Application
         foreach ($commands as $command)
         {
             $class = ModuleConstants::getRootNamespace() . '\App\\' . $this->dir . '\\' . $command;
+
             $this->add(new $class);
         }
     }

+ 2 - 1
core/CommandLine/CronManager.php

@@ -2,6 +2,7 @@
 
 namespace ModulesGarden\ProxmoxAddon\Core\CommandLine;
 
-class CronManager extends Application {
+class CronManager extends Application
+{
     protected $dir = 'Cron';
 }

+ 27 - 19
core/Queue/Manager.php

@@ -5,7 +5,8 @@ namespace ModulesGarden\ProxmoxAddon\Core\Queue;
 use ModulesGarden\ProxmoxAddon\Core\DependencyInjection\DependencyInjection;
 use ModulesGarden\ProxmoxAddon\Core\Queue\Services\Log;
 
-class Manager {
+class Manager
+{
     /**
      * @var Models\Job
      */
@@ -20,41 +21,46 @@ class Manager {
      * Manager constructor.
      * @param Models\Job $job
      */
-    public function __construct(\ModulesGarden\ProxmoxAddon\Core\Queue\Models\Job $job) {
+    public function __construct(\ModulesGarden\ProxmoxAddon\Core\Queue\Models\Job $job)
+    {
         $this->job  = $job;
         $this->log  = new Log($this->job);
     }
 
     /**
-     *  snapshot name 'Snapshot_320_08_30_02' already used
+     *
      */
-    public function fire(){
-        try {
+    public function fire()
+    {
+        try
+        {
             $this->job->setRunning();
 
             $ret    = $this->resolveAndFire($this->job->job, $this->job->data);
-            if($ret !== false) {
+            if($ret !== false)
+            {
                 $this->job->setFinished();
-            } 
-        } catch(\Exception $ex) {
-    	    //Set error in job
+            }
+        }
+        catch(\Exception $ex)
+        {
+            //Set error in job
             $this->job->setError();
-	    $this->job->setRetryAfter(date('Y-m-d H:i:s', strtotime('+ 60 seconds')));
-    	    $this->job->increaseRetryCount();
+            $this->job->setRetryAfter(date('Y-m-d H:i:s', strtotime('+ 60 seconds')));
+            $this->job->increaseRetryCount();
 
-    	    //add log message
-    	    $this->log->error($ex->getMessage(), debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS));
-    	}
+            //add log message
+            $this->log->error($ex->getMessage(), debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS));
+        }
     }
 
-
-
     /**
      * @param $job
      * @param $data
      * @return mixed
      */
-    protected function resolveAndFire($job, $data)  {
+    protected function resolveAndFire($job, $data)
+    {
         list($class, $method)   = $this->parseJob($job);
         $instance               = $this->resolve($class);
 
@@ -65,7 +71,8 @@ class Manager {
      * @param $class
      * @return mixed
      */
-    protected function resolve($class) {
+    protected function resolve($class)
+    {
         return new $class($this->job, $this->log);
     }
 
@@ -75,7 +82,8 @@ class Manager {
      * @param  string  $job
      * @return array
      */
-    protected function parseJob($job)  {
+    protected function parseJob($job)
+    {
         $segments = explode('@', $job);
         return count($segments) > 1 ? $segments : array($segments[0], 'fire');
     }

+ 2 - 1
cron/cron.php

@@ -11,7 +11,8 @@ require_once $modulePath . DS . 'core' . DS . 'Bootstrap.php';
 ini_set('max_execution_time', 0);
 
 $argList = $argv ? $argv : $_SERVER['argv'];
-if (count($argList) === 0) {
+if (count($argList) === 0)
+{
     $argList = [__FILE__];
 }
 

+ 2 - 2
moduleVersion.php

@@ -6,5 +6,5 @@
  */
 
 $moduleVersion = '3.4.0';
-$moduleRevision = '42e8546c5004f40ea05a32823d432489281fd980';
-$moduleWikiUrl = 'http://www.docs.modulesgarden.com/Proxmox_Cloud_For_WHMCS';
+$moduleRevision = 'df118fd9f7a4c7adbd268e8cec4cff51cc9accd2';
+$moduleWikiUrl = 'http://www.docs.modulesgarden.com/Proxmox_VPS_For_WHMCS';