-
Notifications
You must be signed in to change notification settings - Fork 6
Advanced paths configuration
Although IP Monitor is a portable application it can be configured to use different paths in which its different components can be located. For example, it is possible to change the path in which logs are stored. The following steps will detail how it is possible to create a more flexible directory structure such as this one:
-
config: will contain the configuration file -
jars: will contain the IPMonitor.jar file as well as the libraries -
last-check: will contain the the last file with the last check -
some-logs: will contain the application logs -
wrapper-script: will contain the native scripts that call the binaries for the appropriate operative system
All these directories will be assumed to be in /sample-path or C:\sample-path directories for the sake of simplicity but they can be placed anywhere in the filesystem.
Considering IP Monitor is composed of both, a GUI application and a service/daemon, it is needed to modify the way both of them are launched.
-
Create a directory structure similar to this one:
sample-path | + config + jars + last-check + some-logs + wrapper-script -
Place the
libdirectory from the IP Monitor release in thejarsdirectory -
Place the
IPMonitor.jarin thejarsdirectory (it must be in the same directory as thelibdirectory) -
Place the contents of the
files/jswdirectory intowrapper-script -
Edit the
wrapper-script/wrapper.conffile and turn these lines:wrapper.working.dir=../../.. wrapper.java.classpath.1=IPMonitor.jar wrapper.java.classpath.2=lib/javamail/javax.mail.jar wrapper.java.classpath.3=lib/jsw/lib/wrapper.jar wrapper.java.classpath.4=lib/apache-commons/commons-cli-1.3.1.jar wrapper.java.library.path.1=lib/jsw/lib wrapper.app.parameter.2=--config-file-path= wrapper.app.parameter.3=--log-directory-path= wrapper.app.parameter.4=--last-check-file-path= wrapper.app.parameter.5=--wrapper-executable-directory-path= wrapper.app.parameter.6=--wrapper-script-directory-path= wrapper.logfile=files/jsw/wrapper.loginto:
#wrapper.working.dir=../../.. wrapper.java.classpath.1=/sample-path/jars/IPMonitor.jar wrapper.java.classpath.2=/sample-path/jars/lib/javamail/javax.mail.jar wrapper.java.classpath.3=/sample-path/jars/lib/jsw/lib/wrapper.jar wrapper.java.classpath.4=/sample-path/jars/lib/apache-commons/commons-cli-1.3.1.jar wrapper.java.library.path.1=/sample-path/jars/lib/jsw/lib wrapper.app.parameter.2=--config-file-path=/sample-path/config/ipmon.config wrapper.app.parameter.3=--log-directory-path=/sample-path/some-logs wrapper.app.parameter.4=--last-check-file-path=/sample-path/last-check/last.txt wrapper.app.parameter.5=--wrapper-executable-directory-path=/sample-path/lib/jsw/bin wrapper.app.parameter.6=--wrapper-script-directory-path=/sample-path/wrapper-script wrapper.logfile=/sample-path/wrapper-script/wrapper.logNote that you might also need to update this line:
wrapper.java.command=javain order for it to reflect the path to the executable Java file you want to use, if it is not in your path.
-
Edit the native scripts:
If using Linux/Mac (or any other *nix-based OS), edit the
wrapper-script\IPMonitor.shfile and turn this line:WRAPPER_CMD="../../lib/jsw/bin/wrapper"into:
WRAPPER_CMD="/sample-path/jars/lib/jsw/bin/wrapper"If using Windows, edit the
wrapper-script\IPMonitor.batfile and turn these lines:set _WRAPPER_DIR="../../lib/jsw/bin" set _WRAPPER_CONF="../../../files/jsw/%_WRAPPER_BASE%.conf"into:
set _WRAPPER_DIR="C:\sample-path\jars\lib\jsw\bin" set _WRAPPER_CONF="C:\sample-path\wrapper-script\%_WRAPPER_BASE%.conf" -
Create an application launcher that will launch IP Monitor with the custom paths:
-
If using Linux/Mac you can create a shell script with this content, adding the appopriate shebang, if needed (or just a symlink, removing the
\characters and turning it into a single-line command):java -jar /sample-path/jars/IPMonitor.jar \ --config-file-path=/sample-path/config/ipmon.config \ --log-directory-path=/sample-path/some-logs \ --last-check-file-path=/sample-path/last-check/last.txt \ --wrapper-executable-directory-path=/sample-path/libraries/jsw/bin \ --wrapper-script-directory-path=/sample-path/wrapper-script -
If using Windows you can create a batch (
.bat) file with this content (or just a link, removing the^characters and turning it into a single-line command):start javaw -jar C:\sample-path\jars\IPMonitor.jar ^ --config-file-path=C:\sample-path\config\ipmon.config ^ --log-directory-path=C:\sample-path\some-logs ^ --last-check-file-path=C:\sample-path\last-chec\last.txt ^ --wrapper-executable-directory-path=C:\sample-path\libraries\jsw\bin ^ --wrapper-script-directory-path=C:\sample-path\wrapper-script
-
-
In order to test if everything is working you can:
-
Enable debugging of the service/daemon
-
Open a terminal in
wrapper-scriptdirectory and execute the following command: -
If using Linux/Mac run:
./IPMonitor.sh console -
If using Windows run:
IPMonitor.bat --console -
It is possible to troubleshoot the service/daemon by executing the application from the custom launcher and get the service/daemon execution results while trying to install/uninstall/start/stop/test it.
-
Execute the application and enable the logging feature in order to test the log generation. Accept the options and restart the service/daemon, if it happens to be running so that it can read the newly updated values
-
In the
last-checkdirectory you should see the filelast.txtwhenever the service/daemon runs -
Having closed the application or accepted the new settings (which saves the configuration to a file), you should see the
ipmon.configfile in theconfigdirectory -
If the service/daemon has been run and the logging paths are properly configured you should see at least a file in the
some-logsdirectory
-