-
Notifications
You must be signed in to change notification settings - Fork 270
/
tuleap.php
340 lines (313 loc) · 11.9 KB
/
tuleap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<?php
/**
* Copyright (c) Enalean, 2015-present. All Rights Reserved.
*
* This file is a part of Tuleap.
*
* Tuleap is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* Tuleap is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNEsemantic_status FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Tuleap. If not, see <http://www.gnu.org/licenses/>.
*/
use Symfony\Component\Lock\LockFactory;
use Symfony\Component\Lock\Store\SemaphoreStore;
use Tuleap\Authentication\SplitToken\SplitTokenVerificationStringHasher;
use Tuleap\CLI\Application;
use Tuleap\CLI\CLICommandsCollector;
use Tuleap\CLI\Command\ConfigDumpCommand;
use Tuleap\CLI\Command\ConfigGetCommand;
use Tuleap\CLI\Command\ConfigListCommand;
use Tuleap\CLI\Command\ConfigResetCommand;
use Tuleap\CLI\Command\ConfigSetCommand;
use Tuleap\CLI\Command\DailyJobCommand;
use Tuleap\CLI\Command\HealthCheckCommand;
use Tuleap\CLI\Command\ImportProjectXMLCommand;
use Tuleap\CLI\Command\LaunchEveryMinuteJobCommand;
use Tuleap\CLI\Command\ProcessSystemEventsCommand;
use Tuleap\CLI\Command\QueueSystemCheckCommand;
use Tuleap\CLI\Command\UserPasswordCommand;
use Tuleap\CLI\Command\WorkerSupervisorCommand;
use Tuleap\CLI\Command\WorkerSystemCtlCommand;
use Tuleap\CLI\DelayExecution\ConditionalTuleapCronEnvExecutionDelayer;
use Tuleap\CLI\DelayExecution\ExecutionDelayedLauncher;
use Tuleap\CLI\DelayExecution\ExecutionDelayerRandomizedSleep;
use Tuleap\Config\ConfigDao;
use Tuleap\Config\GetConfigKeys;
use Tuleap\Dao\UserSuspensionDao;
use Tuleap\DB\DBFactory;
use Tuleap\FRS\CorrectFrsRepositoryPermissionsCommand;
use Tuleap\InviteBuddy\InvitationCleaner;
use Tuleap\InviteBuddy\InvitationDao;
use Tuleap\Language\LocaleSwitcher;
use Tuleap\Password\PasswordSanityChecker;
use Tuleap\Plugin\PluginInstallCommand;
use Tuleap\Project\Registration\Template\Upload\ProjectArchiveOngoingUploadDao;
use Tuleap\Queue\TaskWorker\TaskWorkerProcessCommand;
use Tuleap\Queue\WorkerLogger;
use Tuleap\User\AccessKey\AccessKeyDAO;
use Tuleap\User\AccessKey\AccessKeyRevoker;
use Tuleap\User\Profile\ForceRegenerationDefaultAvatarCommand;
use Tuleap\User\UserSuspensionManager;
use TuleapCfg\Command\ProcessFactory;
(static function () {
require_once __DIR__ . '/../vendor/autoload.php';
$execution_launcher = new ExecutionDelayedLauncher(
new ConditionalTuleapCronEnvExecutionDelayer(
new ExecutionDelayerRandomizedSleep(59)
)
);
$execution_launcher->execute(
static function () {
// Do nothing
// In a ideal world loading pre.php and doing the setup
// of the CLI command should be done here but there is
// too much code relying on having access to information
// loaded implicitly into $GLOBALS by pre.php.
}
);
})();
require_once __DIR__ . '/../www/include/pre.php';
$event_manager = EventManager::instance();
$backend_logger = BackendLogger::getDefaultLogger();
$user_manager = UserManager::instance();
$CLI_command_collector = new CLICommandsCollector();
$CLI_command_collector->addCommand(
ConfigListCommand::NAME,
static function () use ($event_manager): ConfigListCommand {
return new ConfigListCommand($event_manager);
}
);
$CLI_command_collector->addCommand(
ConfigGetCommand::NAME,
static function () use ($event_manager): ConfigGetCommand {
return new ConfigGetCommand($event_manager);
}
);
$CLI_command_collector->addCommand(
ConfigSetCommand::NAME,
static function () use ($event_manager): ConfigSetCommand {
$config_keys = $event_manager->dispatch(new GetConfigKeys());
assert($config_keys instanceof GetConfigKeys);
return new ConfigSetCommand(
new \Tuleap\Config\ConfigSet(
$config_keys,
new ConfigDao(),
),
$event_manager,
);
}
);
$CLI_command_collector->addCommand(
ConfigDumpCommand::NAME,
static fn () => new ConfigDumpCommand($event_manager)
);
$CLI_command_collector->addCommand(
ConfigResetCommand::NAME,
static function () use ($event_manager) {
$config_keys = $event_manager->dispatch(new GetConfigKeys());
assert($config_keys instanceof GetConfigKeys);
return new ConfigResetCommand(
$config_keys,
new ConfigDao(),
);
}
);
$CLI_command_collector->addCommand(
UserPasswordCommand::NAME,
static function () use ($user_manager): UserPasswordCommand {
return new UserPasswordCommand(
$user_manager,
PasswordSanityChecker::build()
);
}
);
$CLI_command_collector->addCommand(
ImportProjectXMLCommand::NAME,
static function (): ImportProjectXMLCommand {
return new ImportProjectXMLCommand(\Tuleap\DB\DBFactory::getMainTuleapDBConnection());
}
);
$CLI_command_collector->addCommand(
ProcessSystemEventsCommand::NAME,
static function () use ($backend_logger, $event_manager): ProcessSystemEventsCommand {
$store = new SemaphoreStore();
$factory = new LockFactory($store);
return new ProcessSystemEventsCommand(
new SystemEventProcessor_Factory($backend_logger, SystemEventManager::instance(), $event_manager),
DBFactory::getMainTuleapDBConnection(),
$factory
);
}
);
$CLI_command_collector->addCommand(
QueueSystemCheckCommand::NAME,
static function () use ($event_manager): QueueSystemCheckCommand {
return new QueueSystemCheckCommand(
$event_manager,
DBFactory::getMainTuleapDBConnection(),
new ExecutionDelayedLauncher(
new ConditionalTuleapCronEnvExecutionDelayer(
new ExecutionDelayerRandomizedSleep(1799)
)
)
);
}
);
$CLI_command_collector->addCommand(
LaunchEveryMinuteJobCommand::NAME,
static function () use ($event_manager, $backend_logger): LaunchEveryMinuteJobCommand {
return new LaunchEveryMinuteJobCommand(
$event_manager,
$backend_logger,
DBFactory::getMainTuleapDBConnection()
);
}
);
$CLI_command_collector->addCommand(
DailyJobCommand::NAME,
static function () use ($event_manager, $user_manager): DailyJobCommand {
$locale_switcher = new LocaleSwitcher();
$project_archive_dao = new ProjectArchiveOngoingUploadDao();
$project_manager = ProjectManager::instance();
return new DailyJobCommand(
$event_manager,
new AccessKeyRevoker(
new AccessKeyDAO()
),
DBFactory::getMainTuleapDBConnection(),
new ExecutionDelayedLauncher(
new ConditionalTuleapCronEnvExecutionDelayer(
new ExecutionDelayerRandomizedSleep(1799)
)
),
new UserSuspensionManager(
new MailPresenterFactory(),
TemplateRendererFactory::build()->getRenderer(__DIR__ . '/../templates/mail/'),
new Codendi_Mail(),
new UserSuspensionDao(
new InvitationDao(
new SplitTokenVerificationStringHasher(),
new \Tuleap\InviteBuddy\InvitationInstrumentation(\Tuleap\Instrument\Prometheus\Prometheus::instance())
),
),
$user_manager,
new BaseLanguageFactory(),
BackendLogger::getDefaultLogger('usersuspension_syslog'),
$locale_switcher
),
new InvitationCleaner(
new InvitationDao(
new SplitTokenVerificationStringHasher(),
new \Tuleap\InviteBuddy\InvitationInstrumentation(\Tuleap\Instrument\Prometheus\Prometheus::instance())
),
$locale_switcher,
TemplateRendererFactory::build(),
static function (Codendi_Mail $mail) {
$mail->send();
},
UserManager::instance(),
$project_manager,
new \Tuleap\InviteBuddy\InvitationInstrumentation(\Tuleap\Instrument\Prometheus\Prometheus::instance())
),
new \Tuleap\Project\Registration\Template\Upload\ProjectArchiveUploadCleaner(
new \Tuleap\Upload\UploadPathAllocator(ForgeConfig::get('tmp_dir') . '/project/ongoing-upload'),
$project_archive_dao,
$project_archive_dao,
$event_manager,
$project_manager,
$project_manager,
$project_manager,
)
);
}
);
$CLI_command_collector->addCommand(
HealthCheckCommand::NAME,
static function (): HealthCheckCommand {
return new HealthCheckCommand(\Tuleap\Http\HTTPFactoryBuilder::requestFactory());
}
);
$CLI_command_collector->addCommand(
TaskWorkerProcessCommand::NAME,
static function () use ($event_manager): TaskWorkerProcessCommand {
return new TaskWorkerProcessCommand(
$event_manager,
new TruncateLevelLogger(
BackendLogger::getDefaultLogger(basename(WorkerLogger::DEFAULT_LOG_FILE_PATH)),
ForgeConfig::get('sys_logger_level')
),
\Tuleap\Mapper\ValinorMapperBuilderFactory::mapperBuilder()->allowPermissiveTypes()->mapper(),
new \Tuleap\Queue\WorkerEventProcessorFinder(),
);
}
);
$CLI_command_collector->addCommand(
WorkerSupervisorCommand::NAME,
static function (): WorkerSupervisorCommand {
return new WorkerSupervisorCommand(
new ProcessFactory(),
new LockFactory(new SemaphoreStore()),
new \Tuleap\Queue\WorkerAvailability(),
\Tuleap\CLI\AssertRunner::asHTTPUser()
);
}
);
$CLI_command_collector->addCommand(
WorkerSystemCtlCommand::NAME,
static function (): WorkerSystemCtlCommand {
return new WorkerSystemCtlCommand(
new ProcessFactory(),
new \Tuleap\Queue\WorkerAvailability()
);
}
);
$CLI_command_collector->addCommand(
CorrectFrsRepositoryPermissionsCommand::NAME,
function (): CorrectFrsRepositoryPermissionsCommand {
return new CorrectFrsRepositoryPermissionsCommand(
ForgeConfig::get('ftp_frs_dir_prefix'),
ProjectManager::instance()
);
}
);
$CLI_command_collector->addCommand(
ForceRegenerationDefaultAvatarCommand::NAME,
static function (): ForceRegenerationDefaultAvatarCommand {
return new ForceRegenerationDefaultAvatarCommand(
UserManager::instance(),
new UserDao()
);
}
);
$CLI_command_collector->addCommand(
PluginInstallCommand::NAME,
static function (): PluginInstallCommand {
return new PluginInstallCommand(PluginManager::instance());
}
);
$CLI_command_collector->addCommand(
\Tuleap\Queue\WorkerEnqueueCommand::NAME,
static fn () => new \Tuleap\Queue\WorkerEnqueueCommand(),
);
$CLI_command_collector->addCommand(
\Tuleap\System\CollectSystemDataCommand::NAME,
static fn () => new \Tuleap\System\CollectSystemDataCommand(EventManager::instance()),
);
$CLI_command_collector->addCommand(
\Tuleap\Http\Client\SmokescreenDumpConfigurationCommand::NAME,
static fn () => new \Tuleap\Http\Client\SmokescreenDumpConfigurationCommand(
\Tuleap\Http\Client\SmokescreenConfiguration::fromForgeConfig(),
),
);
$event_manager->dispatch($CLI_command_collector);
$application = new Application();
$CLI_command_collector->loadCommands($application);
$application->run();