4 Commits
v1.0 ... v1.0.3

3 changed files with 27 additions and 3 deletions

View File

@@ -1,3 +1,22 @@
# sprinkle-worker
"Background" worker sprinkle for userfrosting
"Background" worker sprinkle for userfrosting
The following snippit creates a single worker thread for processing tasks:
```
[Unit]
Description=UserFrosting workers service
[Service]
Restart=on-failure
Type=simple
PIDFile=/run/uf-workers.pid
ExecStart=php bakery worker:run --quiet
WorkingDirectory=/srv/UserFrosting
User=www-data
Group=www-data
SyslogIdentifier=UF-worker
[Install]
WantedBy=multi-user.target
```

View File

@@ -96,13 +96,18 @@ class JobInspector
$basePath = str_replace($file->getBasename(), '', $file->getBasePath());
$name = $basePath . $file->getFilename();
$className = str_replace('/', '\\', $basePath) . $file->getFilename();
$classPath = "\\$sprinkleNS\\Worker\\Jobs\\$className";
$classPath = "\\$sprinkleNS\\Jobs\\$className";
// Exclude known helper classes
if ($className == "JobInterface" || $className == "JobBase" || $className == "JobInspector") {
return null;
}
$reflect = new \ReflectionClass($classPath);
if ($reflect->isAbstract()) {
return null;
}
// Build the class name and namespace
return [
'sprinkle' => $sprinkleName,

View File

@@ -175,7 +175,7 @@ class Worker
}
$this->queuedJob->save();
} catch(Exception $ex) {
} catch(\Exception $ex) {
if ($this->debug) $this->debug->error('Job execution failed!', [$ex]);
$io->error('An exception occurred attempting to run a job');