e5fc90eb67
This supports automatic site initialization on Gerrit server startup when Gerrit runs in a servlet container. Both creation of a new site and upgrade of an existing site are supported. This feature may be useful for such setups where Gerrit admins don't have direct access to the database and the file system of the server where Gerrit should be deployed and, therefore, cannot perform the init from their local machine prior to deploying Gerrit on such a server. It may also make deployment and testing in a local servlet container faster to setup as the init step could be skipped. The site initialization will be performed only if the 'gerrit.init' system property exists (the value of the property is not, used only the existence of the property matters). If the 'gerrit.site_path' system property is defined then the init is run for that site. The database connectivity, in that case, is defined in the etc/gerrit.config. If 'gerrit.site_path' is not defined then Gerrit will try to find an existing site by looking into the system_config table in the database defined via the 'jdbc/ReviewDb' JNDI property. If system_config table exists then the site_path from that table is used for initialization. Database connectivity is defined by the jdbc/ReviewDb JNDI property. Finally, if neither 'gerrit.site_path' property nor the system_config table exists, the 'gerrit.init_path' system property, if defined, will be used to determine the site path. Database connectivity, also for this case,is defined by the jdbc/ReviewDb JNDI property. Example 1: Prepare Tomcat so that a site is initialized at a given path using the H2 database (if the site doesn't exist yet) or using whatever database is defined in the etc/gerrit.config of that site: $ export CATALINA_OPTS='-Dgerrit.init -Dgerrit.site_path=/path/to/site' $ catalina.sh start Example 2: Prepare Tomcat so that an existing site with the path defined in the system_config table is initialized (upgraded) on Gerrit startup. The assumption is that the jdbc/ReviewDb JNDI property is defined in Tomcat: $ export CATALINA_OPTS='-Dgerrit.init' $ catalina.sh start Example 3: Assuming the database schema doesn't exist in the database defined via the jdbc/ReviewDb JNDI property, initialize a new site using that database and a given path: $ export CATALINA_OPTS='-Dgerrit.init -Dgerrit.init_path=/path/to/site' $ catalina.sh start Change-Id: Ic3e8c993087d2fbb38e14479a539dc62495ad908
120 lines
3.9 KiB
Plaintext
120 lines
3.9 KiB
Plaintext
Gerrit Code Review - J2EE Installation
|
|
======================================
|
|
|
|
Description
|
|
-----------
|
|
|
|
Gerrit binary distributions include a standalone Jetty servlet
|
|
container, but are packaged as a standard WAR file to permit easy
|
|
deployment to other existing container installations if using the
|
|
standalone daemon is not desired.
|
|
|
|
Gerrit Code Review can be installed into any J2EE servlet container,
|
|
including popular open source containers such as Jetty or Tomcat, or
|
|
any commercial server which supports the J2EE servlet specification.
|
|
|
|
|
|
Installation
|
|
------------
|
|
|
|
* Complete the link:install.html#createdb[database setup] and
|
|
link:install.html#init[site initialization] tasks described
|
|
in the standard installation documentation.
|
|
|
|
* Stop the embedded daemon that was automatically started by 'init':
|
|
+
|
|
----
|
|
review_site/bin/gerrit.sh stop
|
|
----
|
|
|
|
* Configure JNDI DataSource 'jdbc/ReviewDb'.
|
|
+
|
|
This DataSource must point to the database you created above.
|
|
Don't forget to ensure your JNDI configuration can load the
|
|
necessary JDBC drivers. You may wish to ensure connection pooling
|
|
is configured and enabled within the DataSource.
|
|
|
|
* Deploy the 'gerrit.war' file to your application server.
|
|
+
|
|
The deployment process differs between servers, but typically this
|
|
can be accomplished by copying 'gerrit.war' into the 'webapps/'
|
|
subdirectory of the container's installation.
|
|
|
|
* ('Optional') Install Bouncy Castle Crypto API
|
|
+
|
|
If you enabled Bouncy Castle Crypto during 'init', copy the JAR
|
|
from `'$site_path'/lib` into your servlet container's extensions
|
|
directory so it's available to Gerrit Code Review.
|
|
|
|
* ('Optional') link:config-auto-site-initialization.html[
|
|
Configure Automatic Site Initialization on Startup]
|
|
|
|
|
|
Jetty 7.x
|
|
---------
|
|
These directions will configure Gerrit as the default web
|
|
application, allowing URLs like `http://example.com/4543` to jump
|
|
directly to change 4543.
|
|
|
|
Download and unzip a release version of Jetty. From here on we
|
|
call the unpacked directory `$JETTY_HOME`.
|
|
|
|
* link:http://www.eclipse.org/jetty/downloads.php[Jetty Downloads]
|
|
|
|
If this is a fresh installation of Jetty, move into the installation
|
|
directory and do some cleanup to remove the sample webapps:
|
|
----
|
|
cd $JETTY_HOME
|
|
rm -rf contexts/* webapps/*
|
|
----
|
|
|
|
Copy Gerrit Code Review into the deployment:
|
|
----
|
|
cp ~/gerrit.war webapps/gerrit.war
|
|
java -jar webapps/gerrit.war cat extra/jetty7/gerrit.xml >contexts/gerrit.xml
|
|
----
|
|
|
|
Install the required additional libraries by copying them into the
|
|
`'$JETTY_HOME'/lib/ext` directory:
|
|
|
|
----
|
|
cp ../review_db/lib/* lib/ext/
|
|
java -jar webapps/gerrit.war cat lib/commons-dbcp-1.2.2.jar >lib/ext/commons-dbcp-1.2.2.jar
|
|
java -jar webapps/gerrit.war cat lib/commons-pool-1.5.4.jar >lib/ext/commons-pool-1.5.4.jar
|
|
java -jar webapps/gerrit.war cat lib/h2-1.2.128.jar >lib/ext/h2-1.2.128.jar
|
|
java -jar webapps/gerrit.war cat lib/postgresql-8.4-701.jdbc4.jar >lib/ext/postgresql-8.4-701.jdbc4.jar
|
|
----
|
|
|
|
Edit `'$JETTY_HOME'/contexts/gerrit.xml` to correctly configure
|
|
the database and outgoing SMTP connections, especially the user
|
|
and password fields.
|
|
|
|
If OpenID authentication (or certain enterprise single-sign-on
|
|
solutions) is being used, you may need to increase the
|
|
header buffer size parameter, due to very long header lines
|
|
being used by the OpenID authentication handshake process.
|
|
Add the following to `'$JETTY_HOME'/etc/jetty.xml` under
|
|
`org.eclipse.jetty.server.nio.SelectChannelConnector`:
|
|
|
|
----
|
|
<Set name="headerBufferSize">16384</Set>
|
|
----
|
|
|
|
To start automatically when the system boots, create a start
|
|
script and modify it for your configuration:
|
|
|
|
----
|
|
java -jar webapps/gerrit.war --cat extra/jetty7/gerrit-jetty.sh >/etc/init.d/gerrit-jetty
|
|
vi /etc/init.d/gerrit-jetty
|
|
----
|
|
|
|
[TIP]
|
|
Under Jetty, restarting the web application (e.g. after modifying
|
|
`system_config`) is as simple as touching the context config file:
|
|
`'$JETTY_HOME'/contexts/gerrit.xml`
|
|
|
|
|
|
GERRIT
|
|
------
|
|
Part of link:index.html[Gerrit Code Review]
|