• [Suggestion] Kill process at port before starting OpenKM

  • He we will discuss about how to make customization and improvement to the OpenKM source code.
He we will discuss about how to make customization and improvement to the OpenKM source code.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #19396  by miguelromero
 
I have seen OpenKm to fail at startup sometimes while trying to bind to a port when its busy, in windows enviroment. Didnt test it in linux.
Its really easy to add a batch file before the executing startup.bat and kill all the processes in the desired port:

The following command will print and kill all process and child process in port 2002:
Code: Select all
FOR /F "tokens=5 delims= " %%P IN ('netstat -a -n -o ^| findstr :2002') DO @ECHO TaskKill.exe /PID %%P /T /F
FOR /F "tokens=5 delims= " %%P IN ('netstat -a -n -o ^| findstr :2002') DO TaskKill.exe /PID %%P /T /F
Take in mind that if you want to test it in the command console you must use only one % symbol. ( %P ). Two % are needed inside the .bat batch file.

This script will solve the problem that OpenKM cant kill the process soffice.bin process binded at port 2002, since it automatically tries to run it and needs the port to be completly free.
 #19435  by miguelromero
 
Yes thank you pavila for the tip.

The problem lies when shutting down OpenKM, some child processes are not closed, like one of the soffice.bin instances binded to port 2002.

When you start OpenKM there are two instances of soffice.bin opened listening at port 2002. After you close OpenKM server (java.exe instance), one of the soffice.bin instances is not closed. This causes that next startups of OpenKM server may not be able to bind to port 2002 since there is a child process already binded and sometimes its not able to kill it.
Thats why I think that this script could be usefull to add at the startup of OpenKM.

Tested under Windows 7 Ultimate SP1 and lastest OpenOffice version.
 #19513  by shaardu
 
Actually even i found this error, whenever i restart openkm, i get "this offcemanager is already running" message and files are not previewed/converted!

Where should i put this above script and should i make any change or simply copy/paste?

Thanks
 #19520  by miguelromero
 
hello shaardu, I added it between the following lines, at the beginning of the file openkm\tomcat\bin\startup.bat:
Code: Select all
if "%OS%" == "Windows_NT" setlocal
rem ---------------------------------------------------------------------------
rem Start script for the CATALINA Server
rem
rem $Id: startup.bat 895392 2010-01-03 14:02:31Z kkolinko $
rem ---------------------------------------------------------------------------

rem Kill process at port 2002
FOR /F "tokens=5 delims= " %%P IN ('netstat -a -n -o ^| findstr :2002') DO @ECHO TaskKill.exe /PID %%P /T /F
FOR /F "tokens=5 delims= " %%P IN ('netstat -a -n -o ^| findstr :2002') DO TaskKill.exe /PID %%P /T /F

rem Guess CATALINA_HOME if not defined
set "CURRENT_DIR=%cd%"
if not "%CATALINA_HOME%" == "" goto gotHome
set "CATALINA_HOME=%CURRENT_DIR%"
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.