Skip to content

Advanced paths configuration

pupi1985 edited this page May 14, 2016 · 1 revision

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.

  1. Create a directory structure similar to this one:

    sample-path
      |
      + config
      + jars
      + last-check
      + some-logs
      + wrapper-script
    
  2. Place the lib directory from the IP Monitor release in the jars directory

  3. Place the IPMonitor.jar in the jars directory (it must be in the same directory as the lib directory)

  4. Place the contents of the files/jsw directory into wrapper-script

  5. Edit the wrapper-script/wrapper.conf file 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.log
    

    into:

    #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.log
    

    Note that you might also need to update this line:

    wrapper.java.command=java
    

    in order for it to reflect the path to the executable Java file you want to use, if it is not in your path.

  6. Edit the native scripts:

    If using Linux/Mac (or any other *nix-based OS), edit the wrapper-script\IPMonitor.sh file 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.bat file 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"
    
  7. Create an application launcher that will launch IP Monitor with the custom paths:

    1. 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
      
    2. 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
      
  8. In order to test if everything is working you can:

    1. Enable debugging of the service/daemon

    2. Open a terminal in wrapper-script directory and execute the following command:

    3. If using Linux/Mac run:

      ./IPMonitor.sh console
      
    4. If using Windows run:

      IPMonitor.bat --console
      
    5. 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.

    6. 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

    7. In the last-check directory you should see the file last.txt whenever the service/daemon runs

    8. Having closed the application or accepted the new settings (which saves the configuration to a file), you should see the ipmon.config file in the config directory

    9. If the service/daemon has been run and the logging paths are properly configured you should see at least a file in the some-logs directory

Clone this wiki locally