Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 1 | = Gerrit Code Review - Automatic Site Initialization on Startup |
Sasa Zivkov | e5fc90e | 2013-05-10 15:12:13 +0200 | [diff] [blame] | 2 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 3 | == Description |
Sasa Zivkov | e5fc90e | 2013-05-10 15:12:13 +0200 | [diff] [blame] | 4 | |
| 5 | Gerrit supports automatic site initialization on server startup |
| 6 | when Gerrit runs in a servlet container. Both creation of a new site |
Saša Živkov | 9f058b3 | 2014-02-13 16:10:38 +0100 | [diff] [blame] | 7 | and upgrade of an existing site are supported. By default, all packaged |
| 8 | plugins will be installed when Gerrit is deployed in a servlet container |
| 9 | and the location of the Gerrit distribution can be determined at |
| 10 | runtime. It is also possible to install only a subset of packaged |
David Pursehouse | c19163c | 2017-01-23 06:15:17 +0000 | [diff] [blame] | 11 | plugins or not install any plugins. |
Sasa Zivkov | e5fc90e | 2013-05-10 15:12:13 +0200 | [diff] [blame] | 12 | |
| 13 | This feature may be useful for such setups where Gerrit administrators |
| 14 | don't have direct access to the database and the file system of the |
| 15 | server where Gerrit should be deployed and, therefore, cannot perform |
| 16 | the init from their local machine prior to deploying Gerrit on such a |
| 17 | server. It may also make deployment and testing in a local servlet |
David Pursehouse | c19163c | 2017-01-23 06:15:17 +0000 | [diff] [blame] | 18 | container faster to set up as the init step could be skipped. |
Sasa Zivkov | e5fc90e | 2013-05-10 15:12:13 +0200 | [diff] [blame] | 19 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 20 | == Gerrit Configuration |
Sasa Zivkov | e5fc90e | 2013-05-10 15:12:13 +0200 | [diff] [blame] | 21 | |
| 22 | The site initialization will be performed only if the `gerrit.init` |
David Pursehouse | c19163c | 2017-01-23 06:15:17 +0000 | [diff] [blame] | 23 | system property exists. The value of the property is not used; only the |
| 24 | existence of the property matters. |
Sasa Zivkov | e5fc90e | 2013-05-10 15:12:13 +0200 | [diff] [blame] | 25 | |
| 26 | If the `gerrit.site_path` system property is defined then the init is |
| 27 | run for that site. The database connectivity, in that case, is defined |
| 28 | in the `etc/gerrit.config`. |
| 29 | |
David Ostrovsky | 3329529 | 2016-03-15 12:17:35 +0100 | [diff] [blame] | 30 | `gerrit.site_path` system property must be defined to run the init for |
| 31 | that site. |
Sasa Zivkov | e5fc90e | 2013-05-10 15:12:13 +0200 | [diff] [blame] | 32 | |
Saša Živkov | e90d6e8 | 2014-02-18 12:56:24 +0100 | [diff] [blame] | 33 | [WARNING] |
| 34 | Defining the `jdbc/ReviewDb` JNDI property for an H2 database under the |
David Ostrovsky | 3329529 | 2016-03-15 12:17:35 +0100 | [diff] [blame] | 35 | path defined by `gerrit.site_path` will cause an incomplete auto |
| 36 | initialization and Gerrit will fail to start. |
| 37 | |
David Pursehouse | c19163c | 2017-01-23 06:15:17 +0000 | [diff] [blame] | 38 | Opening a connection to such a database will create a subfolder under the |
Saša Živkov | e90d6e8 | 2014-02-18 12:56:24 +0100 | [diff] [blame] | 39 | site path folder (in order to create the H2 database) and Gerrit will |
David Pursehouse | c19163c | 2017-01-23 06:15:17 +0000 | [diff] [blame] | 40 | no longer consider that site path to be new and, because of that, |
Saša Živkov | e90d6e8 | 2014-02-18 12:56:24 +0100 | [diff] [blame] | 41 | skip some required initialization steps (for example, Lucene index |
| 42 | creation). In order to auto initialize Gerrit with an embedded H2 |
| 43 | database use the `gerrit.site_path` to define the location of the review |
| 44 | site and don't define a JNDI resource with a URL under that path. |
| 45 | |
David Pursehouse | c19163c | 2017-01-23 06:15:17 +0000 | [diff] [blame] | 46 | If the `gerrit.install_plugins` property is not defined then all packaged |
Saša Živkov | 9f058b3 | 2014-02-13 16:10:38 +0100 | [diff] [blame] | 47 | plugins will be installed. If it is defined then it is parsed as a |
David Pursehouse | c19163c | 2017-01-23 06:15:17 +0000 | [diff] [blame] | 48 | comma-separated list of plugin names to install. If the value is an |
Saša Živkov | 9f058b3 | 2014-02-13 16:10:38 +0100 | [diff] [blame] | 49 | empty string then no plugin will be installed. |
| 50 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 51 | === Example 1 |
Sasa Zivkov | e5fc90e | 2013-05-10 15:12:13 +0200 | [diff] [blame] | 52 | |
| 53 | Prepare Tomcat so that a site is initialized at a given path using |
| 54 | the H2 database (if the site doesn't exist yet) or using whatever |
| 55 | database is defined in `etc/gerrit.config` of that site: |
| 56 | |
| 57 | ---- |
| 58 | $ export CATALINA_OPTS='-Dgerrit.init -Dgerrit.site_path=/path/to/site' |
| 59 | $ catalina.sh start |
| 60 | ---- |
| 61 | |
Yuxuan 'fishy' Wang | 61698b1 | 2013-12-20 12:55:51 -0800 | [diff] [blame] | 62 | === Example 2 |
Sasa Zivkov | e5fc90e | 2013-05-10 15:12:13 +0200 | [diff] [blame] | 63 | |
Sasa Zivkov | e5fc90e | 2013-05-10 15:12:13 +0200 | [diff] [blame] | 64 | Assuming the database schema doesn't exist in the database defined |
| 65 | via the `jdbc/ReviewDb` JNDI property, initialize a new site using that |
| 66 | database and a given path: |
| 67 | |
| 68 | ---- |
| 69 | $ export CATALINA_OPTS='-Dgerrit.init -Dgerrit.init_path=/path/to/site' |
| 70 | $ catalina.sh start |
| 71 | ---- |
| 72 | |
| 73 | GERRIT |
| 74 | ------ |
| 75 | Part of link:index.html[Gerrit Code Review] |
Yuxuan 'fishy' Wang | 99cb68d | 2013-10-31 17:26:00 -0700 | [diff] [blame] | 76 | |
| 77 | SEARCHBOX |
| 78 | --------- |