diff --git a/app/Jobs/EduGainAddEntity.php b/app/Jobs/EduGainAddEntity.php new file mode 100644 index 0000000..fa23d27 --- /dev/null +++ b/app/Jobs/EduGainAddEntity.php @@ -0,0 +1,70 @@ +entity = $entity; + } + + /** + * Execute the job. + */ + public function handle(): void + { + $diskName = config('storageCfg.name'); + $folderName = config('storageCfg.edu2edugain'); + try { + if (! Storage::disk($diskName)->exists($folderName)) { + throw new Exception("No $folderName in $diskName"); + } + } catch (Exception $e) { + $this->fail($e); + } + $pathToDirectory = Storage::disk($diskName)->path($folderName); + $lockKey = 'directory-'.md5($pathToDirectory).'-lock'; + $lock = Cache::lock($lockKey, 61); + try { + $lock->block(61); + EntityFacade::saveMetadataToFederationFolder($this->entity->id,$folderName); + + //TODO write custom function to run special MDA script (ask about this) + + // RunMdaScript::dispatch($federation, $lock->owner()); + } catch (Exception $e) { + Log::error($e->getMessage()); + } finally { + if ($lock->isOwnedByCurrentProcess()) { + $lock->release(); + } + } + + + + } +} diff --git a/app/Jobs/FolderAddEntity.php b/app/Jobs/FolderAddEntity.php index fee9f4f..d56af97 100644 --- a/app/Jobs/FolderAddEntity.php +++ b/app/Jobs/FolderAddEntity.php @@ -68,7 +68,7 @@ public function handle(): void $lock = Cache::lock($lockKey, 61); try { - $lock->block(120); + $lock->block(61); EntityFacade::saveMetadataToFederationFolder($this->entity->id, $fedId->federation_id); diff --git a/app/Jobs/RunMdaScript.php b/app/Jobs/RunMdaScript.php index 96073f3..9e02d5c 100644 --- a/app/Jobs/RunMdaScript.php +++ b/app/Jobs/RunMdaScript.php @@ -44,7 +44,7 @@ public function handle(): void $filterArray = explode(', ', $this->federation->filters); $scriptPath = config('storageCfg.mdaScript'); - $command = 'sh '.config('storageCfg.mdaScript'); + $realScriptPath = realpath($scriptPath);