Comments (11)
would exit(0)
work :D ?
from import.
We could either introduce a new type of exception or replace
https://github.com/techdivision/import-app-simple/blob/master/src/Simple.php#L667
by
return $ase->getCode() ?? 1;
so we can throw such an exception with a custom code
from import.
Actually it might be better to introduce a new exception type, because in such cases of allowed stops, we do not need to print the full exception.
Our use case is that we have empty imports in some cases - which are okay - and we do not need to generate an artefact. That's why we simply need to stop the process.
from import.
I think it would be nice to be able to pass an exit code to \TechDivision\Import\ApplicationInterface::stop
and we could then pass the code to \TechDivision\Import\Exceptions\ApplicationStoppedException
which is used as exit code.
from import.
I image it something like this:
https://github.com/techdivision/import-app-simple/blob/master/src/Simple.php#L638-L668
} catch (ApplicationStoppedException $ase) {
// rollback the transaction, if single transaction mode has been configured
if ($this->getConfiguration()->isSingleTransaction()) {
$this->getImportProcessor()->getConnection()->rollBack();
}
// invoke the event that has to be fired after the application rollbacked the
// transaction (if single transaction mode has been activated)
$this->getEmitter()->emit(EventNames::APP_PROCESS_TRANSACTION_FAILURE, $this, $ase);
// finally, if a PID has been set (because CSV files has been found),
// remove it from the PID file to unlock the importer
$this->unlock();
// track the time needed for the import in seconds
$endTime = microtime(true) - $startTime;
// If the exit code is above 0 it's an error that we have to handle like it else it is an expected stop and we gracefully end
if ($ase->getCode() > 0) {
// log a message that the file import failed
foreach ($this->systemLoggers as $systemLogger) {
$systemLogger->error($ase->__toString());
}
// log a message that import has been finished
$this->getSystemLogger()->warning(sprintf('Can\'t finish import with serial %s in %f s', $this->getSerial(), $endTime));
// log the exception message as warning
$this->log($ase->getMessage(), LogLevel::WARNING);
// return the exit code of the exception
return $ase->getCode();
} else {
// log a info message that import has been finished
$this->getSystemLogger()->info($ase->getMessage());
$this->getSystemLogger()->info(sprintf('Execution time for operation with serial %s in %f s', $this->getSerial(), $endTime));
// invoke the event that has to be fired before the application has the transaction
// committed successfully (if single transaction mode has been activated)
$this->getEmitter()->emit(EventNames::APP_PROCESS_TRANSACTION_SUCCESS, $this);
}
}
from import.
#211
techdivision/import-app-simple#29
from import.
Made some pull requests to have something to discuss, but we should also avoid the rollback on finish. Or we find another way to exit the app if nothing is to do, for example with a series of return statements? @DanieliMi
from import.
I think this is a better approach here - so we do not need a PR to the Pacemaker-Core
We define a new LocalFinishedException()
public function process()
{
try {
$this->export(time(), 1);
} catch (LocalFinishedException $e) {
echo $e->getMessage();
return;
}
}
public function getArtefacts() {
....
if (empty($artefacts)) {
throw new LocalFinishedException('Found no simple products to delete.');
}
}
from import.
I don't think this will work because after this there will be following operations executed which will result in Exceptions in this case so we have to stop the whole application.
from import.
true, understood
from import.
@wagnert what do you think?
We have process chains which should be stopped if initial jobs do not produce output, but this should have a success exit-code.
Is there a better way to solve that or do you think our approach is generally feasible?
Currently we use vendor/bin/import-simple .... || true
in our bash script to avoid stopping the general chain, but this also covers up other problems.
from import.
Related Issues (20)
- Interrupt rendering of validation errors up from a configurable number
- Slash in category name HOT 9
- Extract functionality to clean-up empty columns from AbstractOberserver::mergeEntity() method HOT 2
- Refactor PAC-96 image override option
- Mandatory ok file on import:products:price
- Clean-up-empty-columns not work on EAV attributes not serialized in addtional_attributes
- Disable the stock observer on the fly if there are no columns defined that are related to stock. HOT 5
- Call to undefined method TechDivision\Import\Product\UrlRewrite\Services\ProductUrlRewriteProcessor::removeUrlRewrite() HOT 2
- Empty .OK file results in error message
- Change default import directory from var/importexport to var/pacemaker/import
- GLOB_BRACE is not available on Alpine Linux HOT 5
- Add support for NativeMailerHandler
- "Integrity constraint violation: 1048 Column 'entity_id' cannot be null" while importing products HOT 9
- Importing files with CRLF line endings leads to unexpected results HOT 2
- Stricter validation of column 'categories' in product import
- Attribute set group sortorder is not taken into consideration HOT 1
- Attribute visual swatch unable to render properly HOT 2
- Properly support slashes in Category names HOT 1
- url_rewrite key constraint violation when the database has old rewrites HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from import.