Fred's blog

Deploy Bonita Community on OpenShift

by on Mar.22, 2014, under bonita, openshift

Do you want to run your Bonita Community Tomcat instance on Redhat’s Openshift Online, using MySQL?

Bonitasoft community logo Openshift

This post will not go into the details of using OpenShift, but rather focus on making Bonita Community Ed. 6.2.4 work on it, along with MySQL. I will not go into details of a regular installation of Bonita either.

Note to Bonita Subscription users: It is currently impossible to run the Subscription Edition on OpenShift (and most likely other PaaS services), due to not being able to generate license requests. Being one of these users, I raised a ticket to Bonita support, but didn’t get much support for it nor any hope to see it in the future.

Pre-requisites

  • Have a free OpenShift account
  • Have deployed an OpenShift application with the MySQL 5.5 and Tomcat 7 (JBoss EWS 2.0) cartridges
  • Downloaded on your workstation the Bonita BPM deployment Bundle

Note: After your git clone, don’t forget to remove the pom.xml from your git root and the src folder in order to avoid triggering a maven build when git pushing your changes.

git rm -r src/ pom.xml

Configuring Bonita the OpenShift way

If you have already deployed Bonita on one of your own server, you will soon notice that you cannot install it the same way using OpenShift.

Don’t forget that for all these local files you’ll modify, you’ll have to git add, git commit, and git push them.

The .openshift folder

After doing your git clone, you will have a local openshift directory (that we’ll call $OPENSHIFT_LOCAL_HOME), along with whatever apps you have. Let’s assign a few variables for this post purposes. Don’t confuse them with variables that you could find on your OpenShift instance:


$OPENSHIFT_LOCAL_HOME=/Users/fblaise/openshift/
$OPENSHIFT_LOCAL_APP=/Users/fblaise/openshift/quarterback

The gem folders are located under $OPENSHIFT_LOCAL_APP/.openshift. In that folder, you will notice 4 folders, 3 being of interest for now.

markers

Make sure you have an empty file named “java7″ in it. This will tell your application to use java 7. Without it, you’d be running with java 6.

action_hooks

This is where you will configure the environment variables needed to start your Bonita context.

Create a file named pre_start_jbossews-2.0, and put something along these lines inside:

#!/bin/sh

BONITA_HOME="-Dbonita.home=${OPENSHIFT_DATA_DIR}/bonita_home"
DB_OPTS="-Dsysprop.bonita.db.vendor=mysql"
BTM_OPTS="-Dbtm.root=${OPENSHIFT_REPO_DIR} -Dbitronix.tm.configuration=${OPENSHIFT_REPO_DIR}/.openshift/config/bitronix-config.properties"
export CATALINA_OPTS="${CATALINA_OPTS} ${BONITA_HOME} ${DB_OPTS} ${BTM_OPTS} -Dfile.encoding=UTF-8 -Xshare:auto -XX:+HeapDumpOnOutOfMemoryError"

config

This is the place where you will put your .properties file. This what you should have at the end:

ironman:config fblaise$ ls -l1
bitronix-config.properties
bitronix-resources.properties
catalina.policy
catalina.properties
context.xml
logging.properties
postgresql_module.xml
server.xml
settings.base.xml
settings.prod.xml
settings.rhcloud.xml
settings.stg.xml
tomcat-users.xml
web.xml

Bonita and Tomcat configuration

Local files configuration

Not all files need to be modified. Find below the ones that do.

catalina.properties

In your local config folder under $OPENSHIFT_LOCAL_APP/.openshift, edit the catalina.properties. Locate the line starting with “common.loader”, and append the following:

/var/lib/openshift/xxxxxxxxxxxxxxxxxxxx/app-root/data/lib/*.jar

Note that this string will be unique for each of you. the string of “x” above represents your user for your OpenShift instance. You should then get:

common.loader=${catalina.base}/lib,${catalina.base}/lib/*.jar,${catalina.home}/lib,${catalina.home}/lib/*.jar,/var/lib/openshift/xxxxxxxxxxxxxxxxxxxx/app-root/data/lib/*.jar

server.xml

Add the following right above the <GlobalNamingResources> tag:


<!-- Bitronix listener -->
  <Listener className="bitronix.tm.integration.tomcat55.BTMLifecycleListener" />

I think there is also a H2 listener line you should also remove, since we’re using MySQL. Look in that space also.

context.xml

You will notice a resource that is already configured for MySQL, done when you add the MySQL cartridge. Here, we will add our Bonita datasource and bitronix transaction factory. It should look like this:


<!-- Configure Bonita Datasource -->
        <Resource name="bonitaDS" auth="Container" type="javax.sql.DataSource"
        factory="bitronix.tm.resource.ResourceObjectFactory" uniqueName="jdbc/bonitaDSXA" />

        <Transaction factory="bitronix.tm.BitronixUserTransactionObjectFactory" />

        <Resource name="bonitaSequenceManagerDS"
              url="jdbc:mysql://${OPENSHIFT_MYSQL_DB_HOST}:${OPENSHIFT_MYSQL_DB_PORT}/bonita?dontTrackOpenResources=true&amp;amp;amp;amp;amp;amp;useUnicode=true&amp;amp;amp;amp;amp;amp;characterEncoding=UTF-8"
              auth="Container"
              type="javax.sql.DataSource"
              maxActive="17"
              minIdle="5"
              maxWait="10000"
              initialSize="3"
              maxPoolSize="15"
              minPoolSize="3"
              maxConnectionAge="0"
              maxIdleTime="1800"
              maxIdleTimeExcessConnections="120"
              idleConnectionTestPeriod="30"
              acquireIncrement="3"
              validationQuery="SELECT 1"
              validationInterval="30000"
              testConnectionOnCheckout="true"
              removeAbandoned="true"
              logAbandoned="true"
              username="bonita"
              password="bpm"
              driverClassName="com.mysql.jdbc.Driver"
        />

bitronix-resources.properties

There is no variable interpolation in this file, so you will have to get your IP address from your OpenShift instance. You will notice in the block below the variables holding the values you’re looking for


resource.ds1.className=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
resource.ds1.driverProperties.user=bonita
resource.ds1.driverProperties.password=bpm
## NOT INTERPOLATING !! resource.ds1.driverProperties.URL=jdbc:mysql://${OPENSHIFT_MYSQL_DB_HOST}:${OPENSHIFT_MYSQL_DB_PORT}/bonita?dontTrackOpenResources=true&amp;amp;amp;amp;amp;amp;useUnicode=true&amp;amp;amp;amp;amp;amp;characterEncoding=UTF-8
resource.ds1.driverProperties.URL=jdbc:mysql://127.4.139.2:3306/bonita?dontTrackOpenResources=true&amp;amp;amp;amp;amp;amp;useUnicode=true&amp;amp;amp;amp;amp;amp;characterEncoding=UTF-8
resource.ds1.testQuery=SELECT 1

Don’t forget to git commit.

war, bonita_home and libraries

webapps

Copy the bonita.war found in your Bonita download in $OPENSHIFT_LOCAL_APP/webapps. git add and commit.

Libraries

There are several ways to go about that one. I will just present the one I use.

- On your openshift instance

mkdir $OPENSHIFT_DATA_DIR/lib

- scp all the .jar files you will find in your Bonita Community download under Tomcat-6.0.37/lib (without the *h2* ones) to the above directory.
- Don’t forget to put in there your MySQL connector jar file as well.

bonita_home

Upload the bonita_home-6.2.4 (containing the client and server subfolders) to your OpenShift instance, straight into $OPENSHIFT_DATA_DIR.

bonita-platform.properties

Don’t forget to change from h2 to mysql

db.vendor=${sysprop.bonita.db.vendor:mysql}

Push and deploy

Everything should now be set.

Make sure you’ve git added and committed all your local files, that your bonita.war in the local webapps directory, that you’ve removed your pom.xml and

git push

Performing a git push will restart your application, albeit all your cartridges.

You can tail the logs straight from your terminal with

rhc tail <app_name>

You can check out on your web browser as well, see if the login screen shows. Login with your install user then.

Bonita_BPM_Portal_openshift

Of course, since the application will be out on the wild, don’t forget to change Bonita’s default passwords if not already done (i.e., install user, platformAdmin, etc…).

I may have forgotten some things, as I have written this article some time after doing it. Please let me know if things are missing or are wrong.

Share
12 Comments :, , more...

Quickly deploy a mongoDB 3-members replica set with vagrant

by on Mar.02, 2014, under devops

If you quickly need to test a 3-member mongoDB replica set, this post may be for you.

Using Vagrant and VirtualBox, you can quickly deploy 3 linux servers running mongoDB, automatically configured as a replica set with 1 primary and 2 secondaries. The configuration below is to be used for quick test/dev purposes, not production.

Pre-requisites

Download and install VirtualBox and Vagrant on your computer.

Setup vagrant with initial box image

(Optional if you’re using the Vagrantfile in below tarball)
Open up a terminal and type:

vagrant init precise64 http://files.vagrantup.com/precise64.box

Vagrant config files

Virtualbox (default)

Download this tarball in a place of your liking. Untar it. You can edit them as you see fit, but they should get you started.

Mac OSX / Parallels

Thanks to the vagrant-parallels project, you can install the plugin to run vagrant with parallels.

Run the following commands, and download this Vagrantfile:

vagrant plugin install vagrant-parallels
vagrant box add --provider=parallels precise64 http://download.parallels.com/desktop/vagrant/precise64.box

You can then up your VMs by appending to the vagrant up commands:

--provider=parallels

For more info, see the parallels-plugin website.

Try

Go to the newly created directory, and power everything up from the directory where your Vagrantfile resides.

vagrant up

It is important that “mongo1″ gets deployed last, as the provisioning for the replica is done on that node, which will become the master. This is automatic based on the file you just downloaded.

It possible that you get this warning message when the VMs come up:

[mongo3] The guest additions on this VM do not match the installed version of
VirtualBox! In most cases this is fine, but in rare cases it can
prevent things such as shared folders from working properly. If you see
shared folder errors, please make sure the guest additions within the
virtual machine match the version of VirtualBox you have installed on
your host and reload your VM.

Guest Additions Version: 4.2.0
VirtualBox Version: 4.3

This should not matter. It doesn’t for these specific versions, and for the purpose of this article.

In a matter of minutes, your mongoDB replica set will be ready.

Info

The 3 servers are bound to the following IP addresses (VirtualBox / Parallels)

  • mongo1 : 192.168.33.11 / 10.0.0.11
  • mongo2 : 192.168.33.12 / 10.0.0.12
  • mongo3 : 192.168.33.13 / 10.0.0.13
  • You should end up with the following mongoDB configuration, out of mongo1:

    set0:PRIMARY> rs.conf()
    {
    	"_id" : "set0",
    	"version" : 3,
    	"members" : [
    		{
    			"_id" : 0,
    			"host" : "192.168.33.11:27017"
    		},
    		{
    			"_id" : 1,
    			"host" : "mongo3:27017"
    		},
    		{
    			"_id" : 2,
    			"host" : "mongo2:27017"
    		}
    	]
    }
    

    Testing with data

    Insert a line for testing, on the primary node:

    
    set0:PRIMARY> db.something.insert( {test : true} )
    set0:PRIMARY> db.something.find();
    { "_id" : ObjectId("53133ee70a67e2fcfad30e41"), "test" : true }
    
    

    Now, logon to one of the secondary, and query for that data:

    
    set0:SECONDARY> db.something.find();
    error: { "$err" : "not master and slaveOk=false", "code" : 13435 }
    
    

    This is normal. You have to tell Mongo to allow reads on the secondaries.

    
    set0:SECONDARY> rs.slaveOk()
    
    set0:SECONDARY> db.something.find();
    { "_id" : ObjectId("53133ee70a67e2fcfad30e41"), "test" : true }
    
    
    Share
    4 Comments :, , more...

    Get desktop notification for filesystem usage

    by on Jun.04, 2013, under Code and scripts, Linux

    Here is a little un-intrusive script that will alert you whenever your filesystem is going above a certain percentage threshold.
    This was tested under opensuse 12.3, but should really work on any linux running KDE (or at least having the kdialog binary installed).

    You can save it under your user’s bin directory, for example /home/fblaise/bin/alert_fs.sh in my case.

    
    #!/bin/bash    
     
    # Fred Blaise  
    # Cron this script in order to receive passive alerts about filesystem getting full.
    # Set PCT_THRESHOLD to your liking
     
    export DISPLAY=:0
     
    PCT_THRESHOLD=80
    ALERT_TITLE="WARNING: Filesystem almost full"
     
    (
    df -h |grep ^/dev |awk {'print $1,$5,$6'} | \
    while read devfs pctused mntpoint; do                                                                               
            pctnum=${pctused%\%}
            if [[ "${pctnum}" -ge "${PCT_THRESHOLD}" ]]; then
                    kdialog --title "${ALERT_TITLE}" --passivepopup "${devfs} mounted on ${mntpoint} is at ${pctused}."
            fi     
    done
    )
    
    

    Don’t forget to make this shell script executable.

    We could then imagine a crontab looking like this, for checking every 10 minutes:

    -*/10  * * * *	fblaise /home/fblaise/bin/alert_fs.sh
    

    Whenever one of your filesystem crosses the threshold, a passive box will be displayed. I have my bar on the right side of the screen, and the result is the following:

    fs_kdialog

    It is a very basic script. One could add support for choosing what FS types should be monitored, how often to receive notifications. If you do make this better, please share!

    Share
    3 Comments more...

    Monitor your cron jobs with Jenkins

    by on Feb.02, 2013, under Uncategorized

    Have you found yourself having some cron jobs failing for a while before you realize it when checking the user’s mailbox on that machine? How about having a web dashboard that will give you an “at a glance” status of these?

    Here comes Jenkins — http://jenkins-ci.org . The tool is java-based. It is a tool that actually monitors automatic builds of java code for example, or watch over cron jobs. It is meant to be part of the Continuous Integration concept.

    Let’s create a simple example; We will use this job to capture the console output of a trivial command, ls -l. This is on mac OSX.
    Download jenkins from the homepage. Installation is fairly straight forward, and on mac anyway, your browser opens up automatically with http://localhost:8080 to present you with the Jenkins dashboard.

    Let’s create a new job in this interface. Select “Monitor an external job” and give a meaningful name. Press OK.
    Jenkins job creation
    On the next screen, enter a description then save.

    If you go back to the dashboard, your newly created job appears and do not present any data yet.
    dashboard

    - Open a terminal.
    - Set JENKINS_HOME

    export JENKINS_HOME=http:/@localhost:8080/
    

    - Find out where your “jenkins-core” file is. The exact name depends on the version you downloaded.
    On Max OSX, and in my particular case, it is located at

    /Users/Shared/Jenkins/Home/war/WEB-INF/lib/jenkins-core-1.500.jar
    

    Now, we will prepend the actual command we want to monitor with the jenkins java command, and associate it with the job name we created above.

    java -jar /Users/Shared/Jenkins/Home/war/WEB-INF/lib/jenkins-core-1.500.jar "List home directory" ls -l
    

    command line

    If you now go back to the dashboard and hit refresh, you will see the status change.
    Status update dashboard

    Click on the job, and then on the permalink “last build” (if you hover the link, a small pop-up appears)
    build output

    And there you can see your console output
    console output

    Therefore, if you were to have a cron jobs that you want to monitor you would just have to follow the same steps, making sure JENKINS_HOME is exported, and the output under the right job name.
    And you have it all in a web dashboard!

    If you want an example of a well fed dashboard, you can visit apache’s at Apache’s builds website

    Share
    12 Comments more...

    Netgear WNR2200: firmware upgrade makes bonjour/AFP shares unusable

    by on Jan.14, 2013, under Network

    For those having a Netgear WNR2200 router and using Apple stuff at home such as AFP shares for your TimeMachine backup needs, please be aware that updating your firmware from 1.0.0.32 to 1.0.1.x will likely make that unusable. It seems that the bonjour discovery is not coming across anymore.

    After reverting back to 1.0.0.32 (the actual original firmware), everything came back on.

    Your mileage may vary. I’d be interested if you’re impacted or not. Please comment either way, if you have a few spare minutes, and if you were impacted, were you able to fix it? If so, how?

    Cheers.

    Share
    Leave a Comment :, , , , more...

    Flash crashing? Possible workaround

    by on Jun.10, 2012, under Linux, openSUSE

    Flash crashing in FF or GC after some update? (To me, namely flash-player-11.2.202.235-21.1 on my opensuse 12.1 64bits).

    Try to edit /etc/adobe/mms.cfg

    and change

    1
    EnableLinuxHWVideoDecode=1

    to

    1
    EnableLinuxHWVideoDecode=0

    Restart your browser, and try again.

    Share
    2 Comments more...

    Install NetApp onCommand on Linux 64bits

    by on Feb.16, 2012, under Linux, Netapp

    Linux users wanting to use the NetApp onCommand tool on 64bits are granted with the fact that it is not possible to do so.
    Since it is a java application, here is a simple workaround that worked for me (opensuse 12.1 64bits – sun’s java).

    - Download the linux rpm package.
    - Install rpmrebuild
    - Launch the following command:

    rpmrebuild -e -p sysmgr-setup-2-0R1-linux.rpm
    

    - Edit around l.3726, comment out the line that says exit, something like:

    
    then
            echo "ERROR: NetApp OnCommand System Manager 2.0 is not supported on 64-bit Linux"
            echo "OVERRIDING !!"
            #exit 1;
    fi
    
    

    - Continue and install the rpm.

    Go to /opt/NetApp/on_command_system_manager_2.0. If running KDE, start typing ‘netapp’ in your krunner. You should also find it in your menu.

    or launch:

    java -jar SystemManager.jar
    
    Share
    7 Comments more...

    DLNA server with Linux

    by on Feb.05, 2012, under Linux

    uShare does a great a simple job in quickly setting up a dlna server under Linux.

    Under opensuse 12.1:

    Update: ushare is available via software.opensuse.org.

    Edit the /etc/ushare.conf file, at least these 2 options:

    
    USHARE_DIR=/path/where/you/hold/your/movies
    ENABLE_DLNA=yes
    
    

    Then, you can try with an dlna application and you should see a ‘uShare’ share that you can browse and play movies from!

    Share
    13 Comments : more...

    Configure Linux for your OSX Time Machine needs

    by on Feb.05, 2012, under Linux

    Have a Linux around with some free storage space, and you want to backup your Mac? You can configure your Linux box to just appear in your Mac OSX Time Machine configuration.

    I am using Opensuse 12.1 (64bits) here, and the setup is nearly done. Here are just the few extra steps you need to take in order for your Mac to see your storage space and use it as backup. Note that I have done no effort whatsoever to secure the configuration as of now. It functions, but you may want to take it the extra step for added security. This is just a basic setup.

    First, let’s tell avahi that you want to advertise a new service. Create a new file, called afpovertcp.service in /etc/avahi/services:

    <?xml version="1.0" standalone='no'?><!--*-nxml-*-->
    <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
    
    <service-group>
      <name replace-wildcards="yes">%h</name>
      <service>
        <type>_afpovertcp._tcp</type>
        <port>548</port>
      </service>
      <service>
        <type>_device-info._tcp</type>
        <port>548</port>
        <txt-record>model=PowerMac3,5</txt-record>
      </service>
    </service-group>
    
    

    Install the netatalk package, and go configure the afpd.conf file. Go to the end of this file, and uncomment the default line. I had to pass it my actual IP address, because it was not advertising on the right one.

    # default:
    - -tcp -ipaddr 192.168.1.48 -noddp -uamlist uams_dhx.so,uams_dhx2.so -nosavepassword
    
    

    The rest of this file is commented on my box.

    Then, go edit the AppleVolumes.default file in that same folder. At the end, I simply added the path where I wanted my Time Machine backups to go:

    /home/fblaise/mnt/WD15/time_machine     "tm_backups"    options:tm,ea:auto volcharset:UTF8
    

    At this point, you can start your netatalk service:

    service netatalk start
    

    (Edit /etc/init.d/netatalk at l.71. The -n switch takes mandatory parameters apparently, but we’re not using the atalk stuff)

    
        if [ x"${AFPD_RUN}" = x"yes" -a -x /usr/sbin/afpd ] ; then
                echo -n "  Starting afpd ("
                echo -n ${AFPD_UAMLIST} -g ${AFPD_GUEST} \
                   -c ${AFPD_MAX_CLIENTS} 
                   #-c ${AFPD_MAX_CLIENTS} -n ${ATALK_NAME}${ATALK_ZONE}
                echo -n ")"
                startproc /usr/sbin/afpd ${AFPD_UAMLIST} -g ${AFPD_GUEST} \
                    ${AFPD_OPTIONS} \
                   -c ${AFPD_MAX_CLIENTS} 
                   #-c ${AFPD_MAX_CLIENTS} -n "${ATALK_NAME}${ATALK_ZONE}"
                rc_status -v
        fi
    
    

    or just start the afpd daemon with no option, just by typing

    afpd
    

    as root in a terminal.

    You may want to reload the avahi configuration as well with

    avahi-daemon -r
    

    Then, go to your Time Machine preferences, and your Linux box should now show up as an option with the path defined above!

    Share
    8 Comments :, more...

    Disabling USB in BIOS, but still interrupts?

    by on Jan.30, 2012, under Uncategorized

    Disabled USB in bios altogether to try to get rid of high interrupts, making computer nearly unusable:

    %CPU PID USER COMMAND
    6.5 11361 root [kworker/0:0]
    4.6 11479 root [kworker/1:0]
    2.9 2727 fblaise /usr/lib/thunderbird-9.0/thunderbird-bin
    2.2 10609 root [kworker/0:2]
    1.8 2301 fblaise /usr/bin/knotify4
    1.6 10025 root [kworker/1:3]
    1.0 8615 root [kworker/1:1]
    10.5 1373 root /usr/bin/X :0 vt7 -nr -nolisten tcp -auth /var/run/xauth/A:0-CDTMZa
    0.9 9577 root [kworker/0:1]

    (see http://ironman.darthgibus.net/?p=153#comments)

    but procinfo still shows interrupts on usb? Is it not honoring the BIOS settings?

    irq 0: 23907 timer irq 21: 0 uhci_hcd:usb4
    irq 1: 171 i8042 irq 22: 2 ehci_hcd:usb1

    Kernel is 3.0.0-13-generic-pae.

    Any feedback welcome.

    Update: From powertop:

    Top causes for wakeups:
    47.0% (359.8) PS/2 keyboard/mouse/touchpad interrupt
    20.5% (156.8) [Rescheduling interrupts]

    It’s driving me nuts… Now on opensuse 12.1 64bits.

    Share
    3 Comments more...

    Looking for something?

    Use the form below to search the site:

    Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

    Blogroll

    A few highly recommended websites...