Page 1 of 1

[Suggestion] Kill process at port before starting OpenKM

PostPosted:Mon Nov 19, 2012 11:54 am
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.

Re: [Suggestion] Kill process at port before starting OpenKM

PostPosted:Tue Nov 20, 2012 1:03 pm
by pavila
You can also configure OpenKM to start OpenOffice listering in another port.

Re: [Suggestion] Kill process at port before starting OpenKM

PostPosted:Tue Nov 20, 2012 1:15 pm
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.

Re: [Suggestion] Kill process at port before starting OpenKM

PostPosted:Thu Nov 22, 2012 11:40 am
by pavila
Interesting behaviour. I will try in Windows 7 but in Ubuntu / Debian works fine.

Re: [Suggestion] Kill process at port before starting OpenKM

PostPosted:Sun Nov 25, 2012 3:48 am
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

Re: [Suggestion] Kill process at port before starting OpenKM

PostPosted:Mon Nov 26, 2012 11:56 am
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