@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorClusterConfigOptions
4 extends PhabricatorApplicationConfigOptions {
5
6 public function getName() {
7 return pht('Cluster Setup');
8 }
9
10 public function getDescription() {
11 return pht('Configure services to run on a cluster of hosts.');
12 }
13
14 public function getIcon() {
15 return 'fa-sitemap';
16 }
17
18 public function getGroup() {
19 return 'core';
20 }
21
22 public function getOptions() {
23 $databases_type = 'cluster.databases';
24 $databases_help = $this->deformat(pht(<<<EOTEXT
25WARNING: This is a prototype option and the description below is currently pure
26fantasy.
27
28This option allows you to make this service aware of database read replicas so
29it can monitor database health, spread load, and degrade gracefully to
30read-only mode in the event of a failure on the primary host. For help with
31configuring cluster databases, see **[[ %s | %s ]]** in the documentation.
32EOTEXT
33 ,
34 PhabricatorEnv::getDoclink('Cluster: Databases'),
35 pht('Cluster: Databases')));
36
37
38 $intro_href = PhabricatorEnv::getDoclink('Clustering Introduction');
39 $intro_name = pht('Clustering Introduction');
40
41 $search_type = 'cluster.search';
42 $search_help = $this->deformat(pht(<<<EOTEXT
43Define one or more fulltext storage services. Here you can configure which
44hosts will handle fulltext search queries and indexing. For help with
45configuring fulltext search clusters, see **[[ %s | %s ]]** in the
46documentation.
47EOTEXT
48 ,
49 PhabricatorEnv::getDoclink('Cluster: Search'),
50 pht('Cluster: Search')));
51
52 return array(
53 $this->newOption('cluster.addresses', 'list<string>', array())
54 ->setLocked(true)
55 ->setSummary(pht('Address ranges of cluster hosts.'))
56 ->setDescription(
57 pht(
58 'Define a cluster by providing a whitelist of host '.
59 'addresses that are part of the cluster.'.
60 "\n\n".
61 'Hosts on this whitelist have special powers. These hosts are '.
62 'permitted to bend security rules, and misconfiguring this list '.
63 'can make your install less secure. For more information, '.
64 'see **[[ %s | %s ]]**.'.
65 "\n\n".
66 'Define a list of CIDR blocks which whitelist all hosts in the '.
67 'cluster and no additional hosts. See the examples below for '.
68 'details.'.
69 "\n\n".
70 'When cluster addresses are defined, hosts will also '.
71 'reject requests to interfaces which are not whitelisted.',
72 $intro_href,
73 $intro_name))
74 ->addExample(
75 array(
76 '23.24.25.80/32',
77 '23.24.25.81/32',
78 ),
79 pht('Whitelist Specific Addresses'))
80 ->addExample(
81 array(
82 '1.2.3.0/24',
83 ),
84 pht('Whitelist 1.2.3.*'))
85 ->addExample(
86 array(
87 '1.2.0.0/16',
88 ),
89 pht('Whitelist 1.2.*.*'))
90 ->addExample(
91 array(
92 '0.0.0.0/0',
93 ),
94 pht('Allow Any Host (Insecure!)')),
95 $this->newOption('cluster.instance', 'string', null)
96 ->setLocked(true)
97 ->setSummary(pht('Instance identifier for multi-tenant clusters.'))
98 ->setDescription(
99 pht(
100 'WARNING: This is a very advanced option, and only useful for '.
101 'hosting providers running multi-tenant clusters.'.
102 "\n\n".
103 'If you provide an instance identifier here (normally by '.
104 'injecting it with a `%s`), the server will pass it to '.
105 'subprocesses and commit hooks in the `%s` environmental variable.',
106 'PhabricatorConfigSiteSource',
107 'PHABRICATOR_INSTANCE')),
108 $this->newOption('cluster.read-only', 'bool', false)
109 ->setLocked(true)
110 ->setSummary(
111 pht(
112 'Activate read-only mode for maintenance or disaster recovery.'))
113 ->setDescription(
114 pht(
115 'WARNING: This is a prototype option and the description below '.
116 'is currently pure fantasy.'.
117 "\n\n".
118 'Switch the service to read-only mode. In this mode, users will '.
119 'be unable to write new data. Normally, the cluster degrades '.
120 'into this mode automatically when it detects that the database '.
121 'master is unreachable, but you can activate it manually in '.
122 'order to perform maintenance or test configuration.')),
123 $this->newOption('cluster.databases', $databases_type, array())
124 ->setHidden(true)
125 ->setSummary(
126 pht('Configure database read replicas.'))
127 ->setDescription($databases_help),
128 $this->newOption('cluster.search', $search_type, array())
129 ->setLocked(true)
130 ->setSummary(
131 pht('Configure full-text search services.'))
132 ->setDescription($search_help)
133 ->setDefault(
134 array(
135 array(
136 'type' => 'mysql',
137 'roles' => array(
138 'read' => true,
139 'write' => true,
140 ),
141 ),
142 )),
143 );
144 }
145
146}