Logo Virgo

Virgo OSGi and command line

Publié dans OSGi | Marqué avec , , , ,
Share

I already wrote about Virgo, a complete OSGi stack, based on Equinox and easily integrable on Eclipse (eh, it is done for that). Yes, it is possible to launch and manage our Virgo server using Eclipse (read: Let’s work OSGi Virgo on Eclipse), but if you try to launch a big project like Societies, you might may soon be blocked by an ugly Java « Out of memory ». This is because Eclipse is heavily using the Java memory, and if you launch your OSGi server using Eclipse, you increase again this memory usage.
So, what is the solution? It’s easy: don’t launch Virgo using Eclipse, launch it with command line. So, the server will have its own memory cluster. Lets do this.

How to manage Virgo with command lines?

Start

./<VirgoPath>/bin/startup.bat

And even better, use « & » to launch OSGi in an other process, in order to be able to close it correctly using an other command line. You can also use the parameter « clean » to delete logs and temporary files: /serviceability and /work.

./<VirgoPath>/bin/startup.bat -clean &

Stop

./<VirgoPath>/bin/shutdown.bat

But here comes the issue. Sometimes this command line will work, sometimes it will not or will take a lot of times to be performed! But if Virgo is not completely close, you wont be able to launch it again.
Some basic solutions:

  • If you are using basic Windows command prompt, you can try to close the window: it may work
  • You can try to kill all Java processes. This is a problem if your Firefox or Eclipse are also launched.

In my case, I needed to kill the process that was listening on port 9875. That is why I use this command line.

taskkill /F /PID `netstat -o -n -a -b | findstr 0.0:9875 | awk '{print $5}'`

You can use « kill -9 » instead of « taskkill /F /PID » if you are using Linux style command line (in Cygwin for example).

Make it simple to use

In order to make it simple, I have configured three aliases: osgistart, osgistop, osgikill.
I am using Cygwin, so I have added these aliases somewhere in my .bashrc file (generally in your user folder).

alias osgistart='$VIRGO_HOME/bin/startup.bat -clean'
alias osgistop='$VIRGO_HOME/bin/shutdown.bat'
alias osgikill='$VIRGO_HOME/bin/kill.sh'

And I have added the file kill.sh (or kill.bat depending of your configuration) in the « bin » folder of Virgo:

taskkill /F /PID `netstat -o -n -a -b | findstr 0.0:9875 | awk '{print $5}'`

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *