Skip to content

Commit

Permalink
Try to Free resources on every loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitexus committed Dec 19, 2023
1 parent a042602 commit c81e3b8
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
buildimage:
docker build -t vitexsoftware/discomp2abraflexi:latest .

buildx:
docker buildx build . --push --platform linux/arm/v7,linux/arm64/v8,linux/amd64 --tag vitexsoftware/discomp2abraflexi:latest

drun:
docker run --env-file .env vitexsoftware/discomp2abraflexi:latest
3 changes: 1 addition & 2 deletions multiflexi/discomp2abraflexi.multiflexi.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"cmdparams": "",
"deploy": "apt install discomp2abraflexi",
"homepage": "https:\/\/github.com\/Spoje-NET\/discomp2abraflexi",
"ociimage": "docker.io/vitexsoftware/discomp2abraflexi",
"requirements": "AbraFlexi",
"environment": {
"ABRAFLEXI_COMPANY": {
Expand All @@ -33,7 +34,6 @@
"defval": "https:\/\/demo.flexibee.eu:5434",
"required": true
},

"ABRAFLEXI_STORAGE": {
"type": "string",
"description": "Intial storage Code",
Expand Down Expand Up @@ -66,5 +66,4 @@
}
},
"multiflexi": "1.7.2"

}
37 changes: 29 additions & 8 deletions src/Discomp/Importer.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,19 @@ public function __construct()
{
$this->setObjectName();
$this->discomper = new ApiClient();
$this->abraFlexiInit();
if (\Ease\Shared::cfg('APP_DEBUG', false)) {
$this->logBanner();
}
$this->addStatusMessage(_('Supplier Exists'), $this->ensureSupplierExists() ? 'success' : 'error');
$this->addStatusMessage(_('Category Root Exists'), $this->ensureCategoryRootExists() ? 'success' : 'error');
}

/**
* Connect to AbraFlexi
*/
public function abraFlexiInit()
{
$this->sokoban = new \AbraFlexi\Cenik(null, ['ignore404' => true]);
$this->sokoban->setObjectName('Pricelist');
$this->suplier = \AbraFlexi\RO::code(\Ease\Shared::cfg('ABRAFLEXI_DISCOMP_CODE', 'DISCOMP'));
Expand All @@ -148,11 +161,19 @@ public function __construct()
$this->atribut = new RW(null, ['evidence' => 'atribut']);
$this->atributType = new RW(null, ['evidence' => 'typ-atributu', 'ignore404' => true]);
$this->atributType->setObjectName('AttributeType');
if (\Ease\Shared::cfg('APP_DEBUG', false)) {
$this->logBanner();
}
$this->addStatusMessage(_('Supplier Exists'), $this->ensureSupplierExists() ? 'success' : 'error');
$this->addStatusMessage(_('Category Root Exists'), $this->ensureCategoryRootExists() ? 'success' : 'error');
}

/**
* Try to free resources
*/
public function abraFlexiDisconnect()
{
unset($this->sokoban);
unset($this->suplier);
unset($this->pricer);
unset($this->category);
unset($this->atribut);
unset($this->atributType);
}

/**
Expand Down Expand Up @@ -203,9 +224,9 @@ public function freshItems()
$errors = 0;
$freshItems = $this->getFreshItems();
foreach ($freshItems as $pos => $activeItemData) {
$this->sokoban->connectionReset();
$this->category->connectionReset();
$this->sokoban->dataReset();
$this->abraFlexiDisconnect();
$this->abraFlexiInit();

$discompItemCode = $activeItemData['CODE'];
$this->sokoban->setObjectName('(' . $pos . '/' . count($freshItems) . ') StoreItem:' . $discompItemCode);

Expand Down

0 comments on commit c81e3b8

Please sign in to comment.