Skip to content

Commit 0df71d1

Browse files
committed
improved logging for checks and fix typing for env variables
1 parent 3af2745 commit 0df71d1

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ These are read once, when tika/tika.py is initially loaded and used throughout a
3838
7. `TIKA_LOG_PATH` - set to a directory with write permissions and the `tika.log` and `tika-server.log` files will be placed in this directory.
3939
8. `TIKA_PATH` - set to a directory with write permissions and the `tika_server.jar` file will be placed in this directory.
4040
9. `TIKA_JAVA` - set the Java runtime name, e.g., `java` or `java9`
41-
10. `TIKA_STARTUP_SLEEP` - number of seconds to wait per check if Tika server is launched at runtime
42-
11. `TIKA_STARTUP_MAX_RETRY` - number of checks to attempt for Tika server startup if launched at runtime
41+
10. `TIKA_STARTUP_SLEEP` - number of seconds (`float`) to wait per check if Tika server is launched at runtime
42+
11. `TIKA_STARTUP_MAX_RETRY` - number of checks (`int`) to attempt for Tika server startup if launched at runtime
4343

4444
Testing it out
4545
==============

tika/tika.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ def make_content_disposition_header(fn):
168168
"org.apache.tika.language.translate.Lingo24Translator")
169169
TikaClientOnly = os.getenv('TIKA_CLIENT_ONLY', False)
170170
TikaServerClasspath = os.getenv('TIKA_SERVER_CLASSPATH', '')
171-
TikaStartupSleep = os.getenv('TIKA_STARTUP_SLEEP', 5)
172-
TikaStartupMaxRetry = os.getenv('TIKA_STARTUP_MAX_RETRY', 3)
171+
TikaStartupSleep = float(os.getenv('TIKA_STARTUP_SLEEP', 5))
172+
TikaStartupMaxRetry = int(os.getenv('TIKA_STARTUP_MAX_RETRY', 3))
173173
TikaJava = os.getenv("TIKA_JAVA", "java")
174174

175175
Verbose = 0
@@ -640,11 +640,13 @@ def startServer(tikaServerJar, java_path = TikaJava, serverHost = ServerHost, po
640640
# check for INFO string to confirm listening endpoint
641641
if "Started Apache Tika server at" in tika_log_file_tmp.read():
642642
is_started = True
643+
else:
644+
log.warning("Failed to see startup log message; retrying...")
643645
time.sleep(TikaStartupSleep)
644646
try_count += 1
645647

646648
if not is_started:
647-
log.error("Tika startup log message not received after %d tries" % (TikaStartupMaxRetry))
649+
log.error("Tika startup log message not received after %d tries." % (TikaStartupMaxRetry))
648650
return False
649651
else:
650652
return True

0 commit comments

Comments
 (0)