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
183 lines
5.9 KiB
Plaintext
183 lines
5.9 KiB
Plaintext
Gerrit Code Review - Standalone Daemon Installation Guide
|
|
=========================================================
|
|
|
|
[[requirements]]
|
|
Requirements
|
|
------------
|
|
To run the Gerrit service, the following requirements must be met on
|
|
the host:
|
|
|
|
* JDK, minimum version 1.6 http://www.oracle.com/technetwork/java/javase/downloads/index.html[Download]
|
|
|
|
You'll also need an SQL database to house the review metadata. You have the
|
|
choice of either using the embedded H2 or to host your own MySQL or PostgreSQL.
|
|
|
|
|
|
[[download]]
|
|
Download Gerrit
|
|
---------------
|
|
|
|
Current and past binary releases of Gerrit can be obtained from
|
|
the downloads page at the project site:
|
|
|
|
* http://code.google.com/p/gerrit/downloads/list[Gerrit Downloads]
|
|
|
|
Download any current `*.war` package. The war will be referred to as
|
|
`gerrit.war` from this point forward, so you may find it easier to
|
|
rename the downloaded file.
|
|
|
|
If you would prefer to build Gerrit directly from source, review
|
|
the notes under link:dev-readme.html[developer setup].
|
|
|
|
include::database-setup.txt[]
|
|
|
|
[[init]]
|
|
Initialize the Site
|
|
-------------------
|
|
|
|
Gerrit stores configuration files, the server's SSH keys, and the
|
|
managed Git repositories under a local directory, typically referred
|
|
to as `'$site_path'`. If the embedded H2 database is being used,
|
|
its data files will also be stored under this directory.
|
|
|
|
You also have to decide where to store your server side git repositories. This
|
|
can either be a relative path under `'$site_path'` or an absolute path
|
|
anywhere on your server system. You have to choose a place before commencing
|
|
your init phase.
|
|
|
|
Initialize a new site directory by running the init command, passing
|
|
the path of the site directory to be created as an argument to the
|
|
'-d' option. Its recommended that Gerrit Code Review be given its
|
|
own user account on the host system:
|
|
|
|
----
|
|
sudo adduser gerrit2
|
|
sudo su gerrit2
|
|
|
|
java -jar gerrit.war init -d /path/to/your/gerrit_application_directory
|
|
----
|
|
|
|
'Please note:' If you choose a location where your new user doesn't
|
|
have any privileges, you may have to manually create the directory first and
|
|
then give ownership of that location to the `'gerrit2'` user.
|
|
|
|
If run from an interactive terminal, the init command will prompt through a
|
|
series of configuration questions, including gathering information
|
|
about the database created above. If the terminal is not interactive,
|
|
running the init command will choose some reasonable default selections,
|
|
and will use the embedded H2 database. Once the init phase is complete,
|
|
you can review your settings in the file `'$site_path/etc/gerrit.config'`.
|
|
|
|
When running the init command, additional JARs might be downloaded to
|
|
support optional selected functionality. If a download fails a URL will
|
|
be displayed and init will wait for the user to manually download the JAR
|
|
and store it in the target location.
|
|
|
|
When the init phase is complete, the daemon will be automatically started
|
|
in the background and your web browser will open to the site:
|
|
|
|
----
|
|
Initialized /home/gerrit2/review_site
|
|
Executing /home/gerrit2/review_site/bin/gerrit.sh start
|
|
Starting Gerrit Code Review: OK
|
|
Waiting for server to start ... OK
|
|
Opening browser ...
|
|
----
|
|
|
|
When the browser opens, sign in to Gerrit through the web interface.
|
|
The first user to sign-in and register an account will be
|
|
automatically placed into the fully privileged Administrators group,
|
|
permitting server management over the web and over SSH. Subsequent
|
|
users will be automatically registered as unprivileged users.
|
|
|
|
|
|
Installation Complete
|
|
---------------------
|
|
|
|
Your base Gerrit server is now installed and running. You're now ready to
|
|
either set up more projects or start working with the projects you've already
|
|
imported.
|
|
|
|
|
|
[[project_setup]]
|
|
Project Setup
|
|
-------------
|
|
|
|
See link:project-setup.html[Project Setup] for further details on
|
|
how to register a new project with Gerrit. This step is necessary
|
|
if existing Git repositories were not imported during 'init'.
|
|
|
|
|
|
[[rc_d]]
|
|
Start/Stop Daemon
|
|
-----------------
|
|
|
|
To control the Gerrit Code Review daemon that is running in the
|
|
background, use the rc.d style start script created by 'init':
|
|
|
|
====
|
|
review_site/bin/gerrit.sh start
|
|
review_site/bin/gerrit.sh stop
|
|
review_site/bin/gerrit.sh restart
|
|
====
|
|
|
|
('Optional') Link the gerrit.sh script into rc3.d so the daemon
|
|
automatically starts and stops with the operating system:
|
|
|
|
====
|
|
sudo ln -snf `pwd`/review_site/bin/gerrit.sh /etc/init.d/gerrit
|
|
sudo ln -snf /etc/init.d/gerrit /etc/rc3.d/S90gerrit
|
|
====
|
|
|
|
To install Gerrit into an existing servlet container instead of using
|
|
the embedded Jetty server, see
|
|
link:install-j2ee.html[J2EE installation].
|
|
|
|
|
|
[[customize]]
|
|
Site Customization
|
|
------------------
|
|
|
|
Gerrit Code Review supports some site-specific customization options.
|
|
For more information, see the related topics in this manual:
|
|
|
|
* link:config-reverseproxy.html[Reverse Proxy]
|
|
* link:config-sso.html[Single Sign-On Systems]
|
|
* link:config-themes.html[Themes]
|
|
* link:config-gitweb.html[Gitweb Integration]
|
|
* link:config-gerrit.html[Other System Settings]
|
|
* link:config-auto-site-initialization.html[Automatic Site Initialization on Startup]
|
|
|
|
|
|
[[anonymous_access]]
|
|
Anonymous Access
|
|
----------------
|
|
|
|
Exporting the Git repository directory
|
|
(link:config-gerrit.html#gerrit.basePath[gerrit.basePath]) over the
|
|
anonymous, unencrypted git:// protocol is more efficient than
|
|
Gerrit's internal SSH daemon. See the `git-daemon` documentation
|
|
for details on how to configure this if anonymous access is desired.
|
|
|
|
* http://www.kernel.org/pub/software/scm/git/docs/git-daemon.html[man git-daemon]
|
|
|
|
|
|
[[plugins]]
|
|
Plugins
|
|
-------
|
|
|
|
Place Gerrit plugins in the review_site/plugins directory to have them loaded on Gerrit startup.
|
|
|
|
|
|
External Documentation Links
|
|
----------------------------
|
|
|
|
* http://www.postgresql.org/docs/[PostgreSQL Documentation]
|
|
* http://dev.mysql.com/doc/[MySQL Documentation]
|
|
* http://www.kernel.org/pub/software/scm/git/docs/git-daemon.html[git-daemon]
|
|
|
|
|
|
GERRIT
|
|
------
|
|
Part of link:index.html[Gerrit Code Review]
|