Difference between revisions of "EclipseRT for Amazon EC2"

From Eclipsepedia

Jump to: navigation, search
(Using the OSGi console)
m (Accessing the OSGi console via Telnet)
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Introduction==
+
== Introduction ==
  
The [http://www.eclipse.org/eclipsert/ EclipseRT] can be run as a lightweight application server on [http://aws.amazon.com/ec2/ Amazon's EC2] service. Using the EclipseRT 3.6 development stream (currently on Milestone 5, with target release called [[Helios]]), an Amazon Image (AMI) was created using the most recently available build of the [http://www.eclipse.org/equinox Equinox project], as well as [http://www.eclipse.org/jetty Jetty 7.0.1 web server] and the [http://wiki.eclipse.org/Equinox/p2 p2 provisioning platform].
+
The [http://www.eclipse.org/eclipsert/ EclipseRT] can be run as a lightweight application server on [http://aws.amazon.com/ec2/ Amazon's EC2] service. Using the EclipseRT 3.6 development stream (currently on Milestone 5, with target release called [[Helios]]), an Amazon Image (AMI) was created using the most recently available build of the [http://www.eclipse.org/equinox Equinox project], as well as [http://www.eclipse.org/jetty Jetty 7.0.1 web server] and the [http://wiki.eclipse.org/Equinox/p2 p2 provisioning platform].  
  
==Using the Amazon Image==
+
== Using the Amazon Image to Launch an EC2 Instance ==
  
This Amazon Image is a '''Community AMI''', meaning that any EC2 user can retrieve/use this AMI to launch an EC2 instance.
+
This Amazon Image is a '''Community AMI''', meaning that any EC2 user can retrieve/use this AMI to launch an EC2 instance.  
  
AMI ID: '''ami-69d93600'''<br>
+
AMI ID: '''ami-69d93600'''<br> Manifest: '''eclipsert/osgi_eclipsert36_20100311_jetty_linux_x86.manifest.xml'''  
Manifest: '''eclipsert/osgi_eclipsert36_20100311_jetty_linux_x86.manifest.xml'''
+
  
See the [https://console.aws.amazon.com/ec2/home AWS management console] to launch instances, and then within the '''Community AMI''' tab, simply search for 'osgi' and select the AMI ID: '''ami-69d93600'''.
+
See the [https://console.aws.amazon.com/ec2/home AWS management console] to launch instances, and then within the '''Community AMI''' tab, simply search for 'osgi' and select the AMI ID: '''ami-69d93600'''.  
  
==Starting the Jetty Server==
+
== Starting the Jetty Server ==
  
Once the instance has been created and is running (as indicated by the AWS console), ssh to your new EC2 instance as described by the [https://console.aws.amazon.com/ec2/home EC2 management console documentation]. Be sure to login as root.
+
Once the instance has been created and is running (as indicated by the AWS console), ssh to your new EC2 instance as described by the [https://console.aws.amazon.com/ec2/home EC2 management console documentation]. Be sure to login as root.  
  
Once in the unix shell, type the following:
+
Once in the unix shell, type the following:  
  
'''cd /env/osgi_eclipsert36_sb_p2_jetty_7_0_1_linux_x86/jetty-distribution-7.0.1.v20091125'''
+
'''cd /env/osgi_eclipsert36_sb_p2_jetty_7_0_1_linux_x86/jetty-distribution-7.0.1.v20091125'''  
  
Once in this directory, to start the eclipsert server, simply type
+
Once in this directory, to start the eclipsert server, simply type  
  
'''./eclipsert36.sh'''
+
'''./eclipsert36.sh'''  
  
to start the Jetty server. You will see output to the console something like this
+
to start the Jetty server. You will see output to the console something like this  
 
+
<pre>2010-03-11 16:11:29.189:INFO::Logging to StdErrLog::DEBUG=false via org.eclipse.
<pre>
+
2010-03-11 16:11:29.189:INFO::Logging to StdErrLog::DEBUG=false via org.eclipse.
+
 
jetty.util.log.StdErrLog
 
jetty.util.log.StdErrLog
 
2010-03-11 16:11:29.446:INFO::jetty-7.0.1.v20091125
 
2010-03-11 16:11:29.446:INFO::jetty-7.0.1.v20091125
 
2010-03-11 16:11:29.568:INFO::Deploy /env/osgi_eclipsert36_sb_p2_jetty_7_0_1_lin
 
2010-03-11 16:11:29.568:INFO::Deploy /env/osgi_eclipsert36_sb_p2_jetty_7_0_1_lin
ux_x86/jetty-distribution-7.0.1.v20091125/contexts/eclipsert36.xml -> WebAppCont
+
ux_x86/jetty-distribution-7.0.1.v20091125/contexts/eclipsert36.xml -&gt; WebAppCont
 
ext@1d2068d@1d2068d/,null,/env/osgi_eclipsert36_sb_p2_jetty_7_0_1_linux_x86/jett
 
ext@1d2068d@1d2068d/,null,/env/osgi_eclipsert36_sb_p2_jetty_7_0_1_linux_x86/jett
 
y-distribution-7.0.1.v20091125/webapps/eclipsert36.linux.gtk.x86.war
 
y-distribution-7.0.1.v20091125/webapps/eclipsert36.linux.gtk.x86.war
Line 41: Line 38:
 
er.servlet.JspServlet
 
er.servlet.JspServlet
  
osgi>
+
osgi&gt;
</pre>
+
</pre>  
 +
Note the OSGi console prompt. You may issue OSGi console commands into the running OSGi server via this prompt.
  
Note the OSGi console prompt.  You may issue OSGi console commands into the running OSGi server via this prompt.
+
Included with this server is very simple example 'Hello World' application, and you can access this application on your EC2 instance by browsing to:
  
Included with this server is very simple example 'Hello World' application, and you can access this application on your EC2 instance by browsing to:
+
http://&lt;your EC2 instance's public dns address&gt;:8080/hello
  
http://<your EC2 instance's public dns address>:8080/hello
+
For example, here is an EC2 instance running this application
  
For example, here is an EC2 instance running this application
+
http://ec2-75-101-228-69.compute-1.amazonaws.com:8080/hello
  
http://ec2-75-101-228-69.compute-1.amazonaws.com:8080/hello
+
This should result in an EclipseRT '''Hello World!''' page. On the page is some basic OSGi information about the Hello World application, along with a link to other EclipseRT pages, and a link to the source code for the Hello World application.  
  
This should result in an EclipseRT '''Hello World!''' page. On the page is some basic OSGi information about the Hello World application, along with a link to other EclipseRT pages, and a link to the source code for the Hello World application.
+
== Using the OSGi console ==
  
==Using the OSGi console==
+
By entering OSGi console commands into the osgi&gt; prompt, you can examine and manipulate the state of the server as it is running. To get a listing of all of the supported console commands type:
  
By entering OSGi console commands into the osgi> prompt, you can examine and manipulate the state of the server as it is running.  To get a listing of all of the supported console commands type:
+
osgi&gt; '''help'''
  
osgi> '''help'''
+
Note that with the OSGi console, you may stop and start bundles. The Hello World application, for example reports it's '''Bundle Id''' on the output page, and so may be stopped and started from the OSGi console:
  
Note that with the osgi console, you may stop and start bundles.  The Hello World application, for example reports it's Bundle Id on the output page, and so may be stopped and started:
+
osgi&gt; '''start &lt;Bundle Id&gt;'''  
 
+
osgi> '''start <Bundle Id Value on Hello World page>'''
+
  
 
e.g.  
 
e.g.  
  
osgi> '''stop 41'''
+
osgi&gt; '''stop 41'''
 +
 
 +
If you then refresh the browser with this page, the page will no longer be available. But if you then start this application again:
 +
 
 +
osgi&gt; '''start 41'''
 +
 
 +
and then refresh, the page will be accessible once again.
 +
 
 +
== Accessing the OSGi console via Telnet  ==
 +
 
 +
When starting Jetty as described above, it will terminate as soon as you quit your SSH client, which clearly is not want you want if you're intending to use this setup in production. Follow these steps to run Jetty permanently and still be able to access the OSGi console:
 +
 
 +
Download the web application containing the OSGi base framework ('''/env/osgi_eclipsert36_sb_p2_jetty_7_0_1_linux_x86/jetty-distribution-7.0.1.v20091125/eclipsert36.linux.gtk.x86.war''') and edit '''WEB-INF/web.xml'''. Look for the following lines:
 +
<pre>&lt;init-param&gt;
 +
  &lt;param-name&gt;commandline&lt;/param-name&gt;
 +
  &lt;param-value&gt;-console&lt;/param-value&gt;
 +
&lt;/init-param&gt;
 +
</pre>
 +
and change them to
 +
<pre>&lt;init-param&gt;
 +
  &lt;param-name&gt;commandline&lt;/param-name&gt;
 +
  &lt;param-value&gt;-console 7777&lt;/param-value&gt;
 +
&lt;/init-param&gt;
 +
</pre>
 +
This will make the OSGi console available on port 7777 (by the way, this parameter is documented in the [http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/runtime-options.html Eclipse online help].
 +
 
 +
Uplodad the modified web archive to the server and start the server as follows:
 +
 
 +
'''cd /env/osgi_eclipsert36_sb_p2_jetty_7_0_1_linux_x86/jetty-distribution-7.0.1.v20091125'''
 +
 
 +
'''nohup ./eclipsert36.sh &amp;'''  
  
If you then refresh the browser with this page, the page will no longer be available. But if you then:
+
This makes sure the server is run in the background.
  
osgi> '''start 41'''
+
Now, connect to the OSGi console using telnet.
  
And refresh again, the page will be accessible again.
+
'''telnet localhost 7777'''

Latest revision as of 08:01, 9 April 2010

Contents

[edit] Introduction

The EclipseRT can be run as a lightweight application server on Amazon's EC2 service. Using the EclipseRT 3.6 development stream (currently on Milestone 5, with target release called Helios), an Amazon Image (AMI) was created using the most recently available build of the Equinox project, as well as Jetty 7.0.1 web server and the p2 provisioning platform.

[edit] Using the Amazon Image to Launch an EC2 Instance

This Amazon Image is a Community AMI, meaning that any EC2 user can retrieve/use this AMI to launch an EC2 instance.

AMI ID: ami-69d93600
Manifest: eclipsert/osgi_eclipsert36_20100311_jetty_linux_x86.manifest.xml

See the AWS management console to launch instances, and then within the Community AMI tab, simply search for 'osgi' and select the AMI ID: ami-69d93600.

[edit] Starting the Jetty Server

Once the instance has been created and is running (as indicated by the AWS console), ssh to your new EC2 instance as described by the EC2 management console documentation. Be sure to login as root.

Once in the unix shell, type the following:

cd /env/osgi_eclipsert36_sb_p2_jetty_7_0_1_linux_x86/jetty-distribution-7.0.1.v20091125

Once in this directory, to start the eclipsert server, simply type

./eclipsert36.sh

to start the Jetty server. You will see output to the console something like this

2010-03-11 16:11:29.189:INFO::Logging to StdErrLog::DEBUG=false via org.eclipse.
jetty.util.log.StdErrLog
2010-03-11 16:11:29.446:INFO::jetty-7.0.1.v20091125
2010-03-11 16:11:29.568:INFO::Deploy /env/osgi_eclipsert36_sb_p2_jetty_7_0_1_lin
ux_x86/jetty-distribution-7.0.1.v20091125/contexts/eclipsert36.xml -> WebAppCont
ext@1d2068d@1d2068d/,null,/env/osgi_eclipsert36_sb_p2_jetty_7_0_1_linux_x86/jett
y-distribution-7.0.1.v20091125/webapps/eclipsert36.linux.gtk.x86.war
2010-03-11 16:11:29.628:INFO::Extract jar:file:/env/osgi_eclipsert36_sb_p2_jetty
_7_0_1_linux_x86/jetty-distribution-7.0.1.v20091125/webapps/eclipsert36.linux.gt
k.x86.war!/ to /tmp/Jetty_0_0_0_0_8080_eclipsert36.linux.gtk.x86.war____hjvowd/w
ebapp
2010-03-11 16:11:30.218:INFO::NO JSP Support for /, did not find org.apache.jasp
er.servlet.JspServlet

osgi>

Note the OSGi console prompt. You may issue OSGi console commands into the running OSGi server via this prompt.

Included with this server is very simple example 'Hello World' application, and you can access this application on your EC2 instance by browsing to:

http://<your EC2 instance's public dns address>:8080/hello

For example, here is an EC2 instance running this application

http://ec2-75-101-228-69.compute-1.amazonaws.com:8080/hello

This should result in an EclipseRT Hello World! page. On the page is some basic OSGi information about the Hello World application, along with a link to other EclipseRT pages, and a link to the source code for the Hello World application.

[edit] Using the OSGi console

By entering OSGi console commands into the osgi> prompt, you can examine and manipulate the state of the server as it is running. To get a listing of all of the supported console commands type:

osgi> help

Note that with the OSGi console, you may stop and start bundles. The Hello World application, for example reports it's Bundle Id on the output page, and so may be stopped and started from the OSGi console:

osgi> start <Bundle Id>

e.g.

osgi> stop 41

If you then refresh the browser with this page, the page will no longer be available. But if you then start this application again:

osgi> start 41

and then refresh, the page will be accessible once again.

[edit] Accessing the OSGi console via Telnet

When starting Jetty as described above, it will terminate as soon as you quit your SSH client, which clearly is not want you want if you're intending to use this setup in production. Follow these steps to run Jetty permanently and still be able to access the OSGi console:

Download the web application containing the OSGi base framework (/env/osgi_eclipsert36_sb_p2_jetty_7_0_1_linux_x86/jetty-distribution-7.0.1.v20091125/eclipsert36.linux.gtk.x86.war) and edit WEB-INF/web.xml. Look for the following lines:

<init-param>
  <param-name>commandline</param-name>
  <param-value>-console</param-value>
</init-param> 

and change them to

<init-param>
  <param-name>commandline</param-name>
  <param-value>-console 7777</param-value>
</init-param> 

This will make the OSGi console available on port 7777 (by the way, this parameter is documented in the Eclipse online help.

Uplodad the modified web archive to the server and start the server as follows:

cd /env/osgi_eclipsert36_sb_p2_jetty_7_0_1_linux_x86/jetty-distribution-7.0.1.v20091125

nohup ./eclipsert36.sh &

This makes sure the server is run in the background.

Now, connect to the OSGi console using telnet.

telnet localhost 7777