Skip to content

Commit 601db0a

Browse files
committed
!!! [TASK] Remove remains for Tika Server deamon managment
Removes not usable methods for Tika Server daemon management. Fixes: #254
1 parent e00550b commit 601db0a

6 files changed

Lines changed: 1 addition & 615 deletions

File tree

Classes/Process.php

Lines changed: 0 additions & 199 deletions
This file was deleted.

Classes/Service/Tika/ServerService.php

Lines changed: 1 addition & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
namespace ApacheSolrForTypo3\Tika\Service\Tika;
1919

20-
use ApacheSolrForTypo3\Tika\Process;
21-
use ApacheSolrForTypo3\Tika\Utility\FileUtility;
2220
use GuzzleHttp\Exception\BadResponseException;
2321
use Psr\Container\ContainerExceptionInterface;
2422
use Psr\Container\NotFoundExceptionInterface;
@@ -31,9 +29,7 @@
3129
use TYPO3\CMS\Core\Http\RequestFactory;
3230
use TYPO3\CMS\Core\Http\Stream;
3331
use TYPO3\CMS\Core\Http\Uri;
34-
use TYPO3\CMS\Core\Registry;
3532
use TYPO3\CMS\Core\Resource\FileInterface;
36-
use TYPO3\CMS\Core\Utility\CommandUtility;
3733
use TYPO3\CMS\Core\Utility\GeneralUtility;
3834

3935
use function str_starts_with;
@@ -84,97 +80,6 @@ protected function initializeService(): void
8480
}
8581
}
8682

87-
/**
88-
* Initializes a Tika server process.
89-
*/
90-
protected function getProcess(string $arguments = ''): Process
91-
{
92-
$arguments = trim($this->getAdditionalCommandOptions() . ' ' . $arguments);
93-
94-
return GeneralUtility::makeInstance(Process::class, (string)CommandUtility::getCommand('java'), $arguments);
95-
}
96-
97-
/**
98-
* Creates the command to start the Tika server.
99-
*/
100-
protected function getStartCommand(): string
101-
{
102-
$tikaJar = FileUtility::getAbsoluteFilePath($this->configuration['tikaServerPath']);
103-
$command = '-jar ' . escapeshellarg($tikaJar);
104-
$command .= ' -p ' . escapeshellarg($this->configuration['tikaServerPort']);
105-
106-
return escapeshellcmd($command);
107-
}
108-
109-
/**
110-
* Starts the Tika server
111-
*/
112-
public function startServer(): void
113-
{
114-
$process = $this->getProcess($this->getStartCommand());
115-
$process->start();
116-
$pid = $process->getPid();
117-
118-
/** @var Registry $registry */
119-
$registry = GeneralUtility::makeInstance(Registry::class);
120-
$registry->set('tx_tika', 'server.pid', $pid);
121-
}
122-
123-
/**
124-
* Stops the Tika server
125-
*/
126-
public function stopServer(): void
127-
{
128-
$pid = $this->getServerPid();
129-
if ($pid === null) {
130-
return;
131-
}
132-
133-
$process = $this->getProcess();
134-
$process->setPid($pid);
135-
$process->stop();
136-
137-
// unset pid in registry
138-
/** @var Registry $registry */
139-
$registry = GeneralUtility::makeInstance(Registry::class);
140-
$registry->remove('tx_tika', 'server.pid');
141-
}
142-
143-
/**
144-
* Gets the Tika server pid.
145-
*
146-
* Tries to retrieve the pid from the TYPO3 registry first, then using ps.
147-
*
148-
* @return int|null Null if the pid can't be found, otherwise the pid
149-
*/
150-
public function getServerPid(): ?int
151-
{
152-
/** @var Registry $registry */
153-
$registry = GeneralUtility::makeInstance(Registry::class);
154-
$pid = $registry->get('tx_tika', 'server.pid');
155-
156-
if (empty($pid)) {
157-
$process = $this->getProcess($this->getStartCommand());
158-
$pid = $process->findPid();
159-
}
160-
161-
if (empty($pid)) {
162-
return null;
163-
}
164-
165-
return (int)$pid;
166-
}
167-
168-
/**
169-
* Check if the Tika server is running
170-
*/
171-
public function isServerRunning(): bool
172-
{
173-
$pid = $this->getServerPid();
174-
175-
return !empty($pid);
176-
}
177-
17883
/**
17984
* Ping the Tika server
18085
*
@@ -226,7 +131,7 @@ public function getTikaVersion(): string
226131
{
227132
$version = 'unknown';
228133

229-
if ($this->isAvailable() || $this->isServerRunning()) {
134+
if ($this->isAvailable()) {
230135
$version = $this->queryTika($this->createRequestForEndpoint('/version'));
231136
}
232137

0 commit comments

Comments
 (0)