2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2014 Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #include "hphp/runtime/base/runtime-option.h"
28 #include <sys/resource.h>
30 #include "folly/String.h"
32 #include "hphp/util/hdf.h"
33 #include "hphp/util/text-util.h"
34 #include "hphp/util/network.h"
35 #include "hphp/util/logger.h"
36 #include "hphp/util/stack-trace.h"
37 #include "hphp/util/process.h"
38 #include "hphp/util/file-cache.h"
39 #include "hphp/util/log-file-flusher.h"
40 #include "hphp/runtime/base/file-util.h"
42 #include "hphp/parser/scanner.h"
44 #include "hphp/runtime/server/satellite-server.h"
45 #include "hphp/runtime/server/virtual-host.h"
46 #include "hphp/runtime/server/files-match.h"
47 #include "hphp/runtime/server/access-log.h"
49 #include "hphp/runtime/base/type-conversions.h"
50 #include "hphp/runtime/base/builtin-functions.h"
51 #include "hphp/runtime/base/apc-file-storage.h"
52 #include "hphp/runtime/base/extended-logger.h"
53 #include "hphp/runtime/base/simple-counter.h"
54 #include "hphp/runtime/base/memory-manager.h"
55 #include "hphp/runtime/base/hardware-counter.h"
56 #include "hphp/runtime/base/preg.h"
57 #include "hphp/runtime/base/crash-reporter.h"
58 #include "hphp/runtime/base/static-string-table.h"
59 #include "hphp/runtime/base/config.h"
60 #include "hphp/runtime/base/ini-setting.h"
63 ///////////////////////////////////////////////////////////////////////////////
65 const char *RuntimeOption::ExecutionMode
= "";
66 std::string
RuntimeOption::BuildId
;
67 std::string
RuntimeOption::InstanceId
;
68 std::string
RuntimeOption::PidFile
= "www.pid";
70 std::string
RuntimeOption::LogFile
;
71 std::string
RuntimeOption::LogFileSymLink
;
72 int RuntimeOption::LogHeaderMangle
= 0;
73 bool RuntimeOption::AlwaysEscapeLog
= false;
74 bool RuntimeOption::AlwaysLogUnhandledExceptions
= true;
75 bool RuntimeOption::NoSilencer
= false;
76 int RuntimeOption::ErrorUpgradeLevel
= 0;
77 bool RuntimeOption::CallUserHandlerOnFatals
= true;
78 bool RuntimeOption::ThrowExceptionOnBadMethodCall
= true;
79 bool RuntimeOption::LogNativeStackOnOOM
= true;
80 int RuntimeOption::RuntimeErrorReportingLevel
=
81 static_cast<int>(ErrorConstants::ErrorModes::HPHP_ALL
);
82 int RuntimeOption::ForceErrorReportingLevel
= 0;
84 std::string
RuntimeOption::ServerUser
;
86 int RuntimeOption::MaxLoopCount
= 0;
87 int RuntimeOption::MaxSerializedStringSize
= 64 * 1024 * 1024; // 64MB
88 bool RuntimeOption::NoInfiniteRecursionDetection
= false;
89 bool RuntimeOption::WarnTooManyArguments
= false;
90 bool RuntimeOption::EnableHipHopErrors
= true;
91 bool RuntimeOption::AssertActive
= false;
92 bool RuntimeOption::AssertWarning
= false;
93 int64_t RuntimeOption::NoticeFrequency
= 1;
94 int64_t RuntimeOption::WarningFrequency
= 1;
95 int RuntimeOption::RaiseDebuggingFrequency
= 1;
96 int64_t RuntimeOption::SerializationSizeLimit
= StringData::MaxSize
;
97 int64_t RuntimeOption::StringOffsetLimit
= 10 * 1024 * 1024; // 10MB
99 std::string
RuntimeOption::AccessLogDefaultFormat
= "%h %l %u %t \"%r\" %>s %b";
100 std::vector
<AccessLogFileData
> RuntimeOption::AccessLogs
;
102 std::string
RuntimeOption::AdminLogFormat
= "%h %t %s %U";
103 std::string
RuntimeOption::AdminLogFile
;
104 std::string
RuntimeOption::AdminLogSymLink
;
107 std::string
RuntimeOption::Tier
;
108 std::string
RuntimeOption::Host
;
109 std::string
RuntimeOption::DefaultServerNameSuffix
;
110 std::string
RuntimeOption::ServerType
= "libevent";
111 std::string
RuntimeOption::ServerIP
;
112 std::string
RuntimeOption::ServerFileSocket
;
113 std::string
RuntimeOption::ServerPrimaryIP
;
114 int RuntimeOption::ServerPort
= 80;
115 int RuntimeOption::ServerPortFd
= -1;
116 int RuntimeOption::ServerBacklog
= 128;
117 int RuntimeOption::ServerConnectionLimit
= 0;
118 int RuntimeOption::ServerThreadCount
= 50;
119 int RuntimeOption::ProdServerPort
= 80;
120 int RuntimeOption::QueuedJobsReleaseRate
= 3;
121 bool RuntimeOption::ServerThreadRoundRobin
= false;
122 int RuntimeOption::ServerWarmupThrottleRequestCount
= 0;
123 int RuntimeOption::ServerThreadDropCacheTimeoutSeconds
= 0;
124 int RuntimeOption::ServerThreadJobLIFOSwitchThreshold
= INT_MAX
;
125 int RuntimeOption::ServerThreadJobMaxQueuingMilliSeconds
= -1;
126 bool RuntimeOption::ServerThreadDropStack
= false;
127 bool RuntimeOption::ServerHttpSafeMode
= false;
128 bool RuntimeOption::ServerStatCache
= false;
129 bool RuntimeOption::ServerFixPathInfo
= false;
130 std::vector
<std::string
> RuntimeOption::ServerWarmupRequests
;
131 boost::container::flat_set
<std::string
>
132 RuntimeOption::ServerHighPriorityEndPoints
;
133 bool RuntimeOption::ServerExitOnBindFail
;
134 int RuntimeOption::PageletServerThreadCount
= 0;
135 bool RuntimeOption::PageletServerThreadRoundRobin
= false;
136 int RuntimeOption::PageletServerThreadDropCacheTimeoutSeconds
= 0;
137 int RuntimeOption::PageletServerQueueLimit
= 0;
138 bool RuntimeOption::PageletServerThreadDropStack
= false;
139 int RuntimeOption::RequestTimeoutSeconds
= 0;
140 int RuntimeOption::PspTimeoutSeconds
= 0;
141 int64_t RuntimeOption::MaxRequestAgeFactor
= 0;
142 int64_t RuntimeOption::ServerMemoryHeadRoom
= 0;
143 int64_t RuntimeOption::RequestMemoryMaxBytes
=
144 std::numeric_limits
<int64_t>::max();
145 int64_t RuntimeOption::ImageMemoryMaxBytes
= 0;
146 int RuntimeOption::ResponseQueueCount
= 0;
147 int RuntimeOption::ServerGracefulShutdownWait
= 0;
148 bool RuntimeOption::ServerHarshShutdown
= true;
149 bool RuntimeOption::ServerEvilShutdown
= true;
150 bool RuntimeOption::ServerKillOnSIGTERM
= false;
151 int RuntimeOption::ServerDanglingWait
= 0;
152 int RuntimeOption::ServerShutdownListenWait
= 0;
153 int RuntimeOption::ServerShutdownListenNoWork
= -1;
154 std::vector
<std::string
> RuntimeOption::ServerNextProtocols
;
155 int RuntimeOption::GzipCompressionLevel
= 3;
156 int RuntimeOption::GzipMaxCompressionLevel
= 9;
157 std::string
RuntimeOption::ForceCompressionURL
;
158 std::string
RuntimeOption::ForceCompressionCookie
;
159 std::string
RuntimeOption::ForceCompressionParam
;
160 bool RuntimeOption::EnableMagicQuotesGpc
= false;
161 bool RuntimeOption::EnableKeepAlive
= true;
162 bool RuntimeOption::ExposeHPHP
= true;
163 bool RuntimeOption::ExposeXFBServer
= false;
164 bool RuntimeOption::ExposeXFBDebug
= false;
165 std::string
RuntimeOption::XFBDebugSSLKey
;
166 int RuntimeOption::ConnectionTimeoutSeconds
= -1;
167 bool RuntimeOption::EnableOutputBuffering
= false;
168 std::string
RuntimeOption::OutputHandler
;
169 bool RuntimeOption::ImplicitFlush
= false;
170 bool RuntimeOption::EnableEarlyFlush
= true;
171 bool RuntimeOption::ForceChunkedEncoding
= false;
172 int64_t RuntimeOption::MaxPostSize
= 100;
173 bool RuntimeOption::AlwaysPopulateRawPostData
= true;
174 int64_t RuntimeOption::UploadMaxFileSize
= 100;
175 std::string
RuntimeOption::UploadTmpDir
= "/tmp";
176 bool RuntimeOption::EnableFileUploads
= true;
177 bool RuntimeOption::EnableUploadProgress
= false;
178 int64_t RuntimeOption::MaxFileUploads
= 20;
179 int RuntimeOption::Rfc1867Freq
= 256 * 1024;
180 std::string
RuntimeOption::Rfc1867Prefix
= "vupload_";
181 std::string
RuntimeOption::Rfc1867Name
= "video_ptoken";
182 bool RuntimeOption::LibEventSyncSend
= true;
183 bool RuntimeOption::ExpiresActive
= true;
184 int RuntimeOption::ExpiresDefault
= 2592000;
185 std::string
RuntimeOption::DefaultCharsetName
= "utf-8";
186 bool RuntimeOption::ForceServerNameToHeader
= false;
187 bool RuntimeOption::EnableCufAsync
= false;
188 bool RuntimeOption::PathDebug
= false;
190 int RuntimeOption::RequestBodyReadLimit
= -1;
192 bool RuntimeOption::EnableSSL
= false;
193 int RuntimeOption::SSLPort
= 443;
194 int RuntimeOption::SSLPortFd
= -1;
195 std::string
RuntimeOption::SSLCertificateFile
;
196 std::string
RuntimeOption::SSLCertificateKeyFile
;
197 std::string
RuntimeOption::SSLCertificateDir
;
198 bool RuntimeOption::TLSDisableTLS1_2
= false;
199 std::string
RuntimeOption::TLSClientCipherSpec
;
201 std::vector
<std::shared_ptr
<VirtualHost
>> RuntimeOption::VirtualHosts
;
202 std::shared_ptr
<IpBlockMap
> RuntimeOption::IpBlocks
;
203 std::vector
<std::shared_ptr
<SatelliteServerInfo
>>
204 RuntimeOption::SatelliteServerInfos
;
206 int RuntimeOption::XboxServerThreadCount
= 10;
207 int RuntimeOption::XboxServerMaxQueueLength
= INT_MAX
;
208 int RuntimeOption::XboxServerPort
= 0;
209 int RuntimeOption::XboxDefaultLocalTimeoutMilliSeconds
= 500;
210 int RuntimeOption::XboxDefaultRemoteTimeoutSeconds
= 5;
211 int RuntimeOption::XboxServerInfoMaxRequest
= 500;
212 int RuntimeOption::XboxServerInfoDuration
= 120;
213 std::string
RuntimeOption::XboxServerInfoWarmupDoc
;
214 std::string
RuntimeOption::XboxServerInfoReqInitFunc
;
215 std::string
RuntimeOption::XboxServerInfoReqInitDoc
;
216 bool RuntimeOption::XboxServerInfoAlwaysReset
= false;
217 bool RuntimeOption::XboxServerLogInfo
= false;
218 std::string
RuntimeOption::XboxProcessMessageFunc
= "xbox_process_message";
219 std::string
RuntimeOption::XboxPassword
;
220 std::set
<std::string
> RuntimeOption::XboxPasswords
;
222 std::string
RuntimeOption::SourceRoot
= Process::GetCurrentDirectory() + '/';
223 std::vector
<std::string
> RuntimeOption::IncludeSearchPaths
;
224 std::string
RuntimeOption::FileCache
;
225 std::string
RuntimeOption::DefaultDocument
;
226 std::string
RuntimeOption::ErrorDocument404
;
227 bool RuntimeOption::ForbiddenAs404
= false;
228 std::string
RuntimeOption::ErrorDocument500
;
229 std::string
RuntimeOption::FatalErrorMessage
;
230 std::string
RuntimeOption::FontPath
;
231 bool RuntimeOption::EnableStaticContentFromDisk
= true;
232 bool RuntimeOption::EnableOnDemandUncompress
= true;
233 bool RuntimeOption::EnableStaticContentMMap
= true;
235 bool RuntimeOption::Utf8izeReplace
= true;
237 std::string
RuntimeOption::StartupDocument
;
238 std::string
RuntimeOption::WarmupDocument
;
239 std::string
RuntimeOption::RequestInitFunction
;
240 std::string
RuntimeOption::RequestInitDocument
;
241 std::string
RuntimeOption::AutoPrependFile
;
242 std::string
RuntimeOption::AutoAppendFile
;
244 bool RuntimeOption::SafeFileAccess
= false;
245 std::vector
<std::string
> RuntimeOption::AllowedDirectories
;
246 std::set
<std::string
> RuntimeOption::AllowedFiles
;
247 hphp_string_imap
<std::string
> RuntimeOption::StaticFileExtensions
;
248 hphp_string_imap
<std::string
> RuntimeOption::PhpFileExtensions
;
249 std::set
<std::string
> RuntimeOption::ForbiddenFileExtensions
;
250 std::set
<std::string
> RuntimeOption::StaticFileGenerators
;
251 std::vector
<std::shared_ptr
<FilesMatch
>> RuntimeOption::FilesMatches
;
253 bool RuntimeOption::WhitelistExec
= false;
254 bool RuntimeOption::WhitelistExecWarningOnly
= false;
255 std::vector
<std::string
> RuntimeOption::AllowedExecCmds
;
257 bool RuntimeOption::UnserializationWhitelistCheck
= false;
258 bool RuntimeOption::UnserializationWhitelistCheckWarningOnly
= true;
260 std::string
RuntimeOption::TakeoverFilename
;
261 int RuntimeOption::AdminServerPort
= 0;
262 int RuntimeOption::AdminThreadCount
= 1;
263 std::string
RuntimeOption::AdminPassword
;
264 std::set
<std::string
> RuntimeOption::AdminPasswords
;
266 std::string
RuntimeOption::ProxyOrigin
;
267 int RuntimeOption::ProxyRetry
= 3;
268 bool RuntimeOption::UseServeURLs
;
269 std::set
<std::string
> RuntimeOption::ServeURLs
;
270 bool RuntimeOption::UseProxyURLs
;
271 int RuntimeOption::ProxyPercentage
= 0;
272 std::set
<std::string
> RuntimeOption::ProxyURLs
;
273 std::vector
<std::string
> RuntimeOption::ProxyPatterns
;
274 bool RuntimeOption::AlwaysUseRelativePath
= false;
276 int RuntimeOption::HttpDefaultTimeout
= 30;
277 int RuntimeOption::HttpSlowQueryThreshold
= 5000; // ms
279 bool RuntimeOption::TranslateLeakStackTrace
= false;
280 bool RuntimeOption::NativeStackTrace
= false;
281 bool RuntimeOption::FullBacktrace
= false;
282 bool RuntimeOption::ServerErrorMessage
= false;
283 bool RuntimeOption::TranslateSource
= false;
284 bool RuntimeOption::RecordInput
= false;
285 bool RuntimeOption::ClearInputOnSuccess
= true;
286 std::string
RuntimeOption::ProfilerOutputDir
= "/tmp";
287 std::string
RuntimeOption::CoreDumpEmail
;
288 bool RuntimeOption::CoreDumpReport
= true;
289 std::string
RuntimeOption::StackTraceFilename
;
290 bool RuntimeOption::LocalMemcache
= false;
291 bool RuntimeOption::MemcacheReadOnly
= false;
293 bool RuntimeOption::EnableStats
= false;
294 bool RuntimeOption::EnableAPCStats
= false;
295 bool RuntimeOption::EnableWebStats
= false;
296 bool RuntimeOption::EnableMemoryStats
= false;
297 bool RuntimeOption::EnableMemcacheStats
= false;
298 bool RuntimeOption::EnableMemcacheKeyStats
= false;
299 bool RuntimeOption::EnableSQLStats
= false;
300 bool RuntimeOption::EnableSQLTableStats
= false;
301 bool RuntimeOption::EnableNetworkIOStatus
= false;
302 std::string
RuntimeOption::StatsXSL
;
303 std::string
RuntimeOption::StatsXSLProxy
;
304 int RuntimeOption::StatsSlotDuration
= 10 * 60; // 10 minutes
305 int RuntimeOption::StatsMaxSlot
= 12 * 6; // 12 hours
307 int64_t RuntimeOption::MaxRSS
= 0;
308 int64_t RuntimeOption::MaxRSSPollingCycle
= 0;
309 int64_t RuntimeOption::DropCacheCycle
= 0;
310 int64_t RuntimeOption::MaxSQLRowCount
= 0;
311 int64_t RuntimeOption::MaxMemcacheKeyCount
= 0;
312 int64_t RuntimeOption::SocketDefaultTimeout
= 5;
313 bool RuntimeOption::LockCodeMemory
= false;
314 int RuntimeOption::MaxArrayChain
= INT_MAX
;
315 bool RuntimeOption::WarnOnCollectionToArray
= false;
316 bool RuntimeOption::UseDirectCopy
= false;
318 std::map
<std::string
, std::string
> RuntimeOption::ServerVariables
;
319 std::map
<std::string
, std::string
> RuntimeOption::EnvVariables
;
321 std::string
RuntimeOption::LightProcessFilePrefix
= "./lightprocess";
322 int RuntimeOption::LightProcessCount
= 0;
324 bool RuntimeOption::EnableHipHopSyntax
= false;
325 bool RuntimeOption::EnableHipHopExperimentalSyntax
= false;
326 bool RuntimeOption::EnableShortTags
= true;
327 bool RuntimeOption::EnableAspTags
= false;
328 bool RuntimeOption::EnableXHP
= false;
329 bool RuntimeOption::EnableObjDestructCall
= true;
330 bool RuntimeOption::EnableEmitSwitch
= true;
331 bool RuntimeOption::EnableEmitterStats
= true;
332 bool RuntimeOption::CheckSymLink
= true;
333 int RuntimeOption::MaxUserFunctionId
= (2 * 65536);
334 bool RuntimeOption::EnableArgsInBacktraces
= true;
335 bool RuntimeOption::EnableZendCompat
= false;
336 bool RuntimeOption::EnableZendSorting
= false;
337 bool RuntimeOption::TimeoutsUseWallTime
= true;
338 bool RuntimeOption::CheckFlushOnUserClose
= true;
339 bool RuntimeOption::EvalAuthoritativeMode
= false;
340 bool RuntimeOption::IntsOverflowToInts
= false;
342 #ifdef HHVM_DYNAMIC_EXTENSION_DIR
343 std::string
RuntimeOption::ExtensionDir
= HHVM_DYNAMIC_EXTENSION_DIR
;
345 std::string
RuntimeOption::ExtensionDir
= "";
348 std::vector
<std::string
> RuntimeOption::Extensions
;
349 std::vector
<std::string
> RuntimeOption::DynamicExtensions
;
350 std::string
RuntimeOption::DynamicExtensionPath
= ".";
352 std::vector
<void(*)(const IniSettingMap
&, const Hdf
&)>*
353 RuntimeOption::OptionHooks
= nullptr;
355 void RuntimeOption::AddOptionHook(
356 void(*optionHook
)(const IniSettingMap
&, const Hdf
&)) {
357 // assuming no concurrent call to this function
358 if (RuntimeOption::OptionHooks
== nullptr) {
359 RuntimeOption::OptionHooks
=
360 new std::vector
<void(*)(const IniSettingMap
&, const Hdf
&)>();
362 RuntimeOption::OptionHooks
->push_back(optionHook
);
366 RuntimeOption::StrictArrayFillKeys
= HackStrictOption::OFF
,
367 RuntimeOption::DisallowDynamicVarEnvFuncs
= HackStrictOption::OFF
;
368 bool RuntimeOption::LookForTypechecker
= true;
370 int RuntimeOption::GetScannerType() {
372 if (EnableShortTags
) type
|= Scanner::AllowShortTags
;
373 if (EnableAspTags
) type
|= Scanner::AllowAspTags
;
374 if (EnableXHP
) type
|= Scanner::AllowXHPSyntax
;
375 if (EnableHipHopSyntax
) type
|= Scanner::AllowHipHopSyntax
;
379 bool RuntimeOption::GetServerCustomBoolSetting(const std::string
&settingName
,
381 auto it
= RuntimeOption::CustomSettings
.find(settingName
);
382 if (it
== RuntimeOption::CustomSettings
.end()) {
383 // The value isn't present in the CustomSettings section
387 val
= Hdf::convertRawConfigToBool(it
->second
.data());
391 static inline std::string
regionSelectorDefault() {
395 static inline bool pgoDefault() {
397 return !RuntimeOption::EvalSimulateARM
;
400 static inline uint64_t pgoThresholdDefault() {
401 #ifdef HHVM_WHOLE_CFG
404 return debug
? 2 : 10;
408 static inline std::string
pgoRegionSelectorDefault() {
409 #ifdef HHVM_WHOLE_CFG
416 static inline bool loopsDefault() {
417 #ifdef HHVM_JIT_LOOPS_BY_DEFAULT
424 static inline bool controlFlowDefault() {
425 #if defined(HHVM_JIT_LOOPS_BY_DEFAULT) || \
426 defined(HHVM_CONTROL_FLOW) || \
427 defined(HHVM_WHOLE_CFG)
434 static inline bool evalJitDefault() {
435 #if defined(__APPLE__) || defined(__CYGWIN__)
442 static inline bool simulateARMDefault() {
443 #ifdef HHVM_SIMULATE_ARM_BY_DEFAULT
450 static inline bool jitPseudomainDefault() {
452 return !RuntimeOption::EvalSimulateARM
;
457 * 1: use LLVM for TransOptimize translations
458 * 2: use LLVM for all translations
460 static inline uint32_t jitLLVMDefault() {
461 #ifdef HHVM_JIT_LLVM_BY_DEFAULT
468 static inline bool hugePagesSoundNice() {
469 return RuntimeOption::ServerExecutionMode();
472 static inline int nsjrDefault() {
473 return RuntimeOption::ServerExecutionMode() ? 5 : 0;
476 const uint64_t kEvalVMStackElmsDefault
=
483 const uint32_t kEvalVMInitialGlobalTableSizeDefault
= 512;
484 static const int kDefaultProfileInterpRequests
= debug
? 1 : 11;
485 static const uint32_t kDefaultProfileRequests
= debug
? 1 << 31 : 500;
486 static const size_t kJitGlobalDataDef
= RuntimeOption::EvalJitASize
>> 2;
487 static const uint64_t kJitRelocationSizeDefault
= debug
? 1 << 20 : 0;
489 static const bool kJitTimerDefault
=
490 #ifdef ENABLE_JIT_TIMER_DEFAULT
497 inline size_t maxUsageDef() {
498 return RuntimeOption::EvalJitASize
;
501 #define F(type, name, def) \
502 type RuntimeOption::Eval ## name = type(def);
505 std::set
<string
, stdltistr
> RuntimeOption::DynamicInvokeFunctions
;
506 bool RuntimeOption::RecordCodeCoverage
= false;
507 std::string
RuntimeOption::CodeCoverageOutputFile
;
509 std::string
RuntimeOption::RepoLocalMode
;
510 std::string
RuntimeOption::RepoLocalPath
;
511 std::string
RuntimeOption::RepoCentralPath
;
512 std::string
RuntimeOption::RepoEvalMode
;
513 std::string
RuntimeOption::RepoJournal
= "delete";
514 bool RuntimeOption::RepoCommit
= true;
515 bool RuntimeOption::RepoDebugInfo
= true;
516 // Missing: RuntimeOption::RepoAuthoritative's physical location is
518 bool RuntimeOption::RepoPreload
;
520 bool RuntimeOption::SandboxMode
= false;
521 std::string
RuntimeOption::SandboxPattern
;
522 std::string
RuntimeOption::SandboxHome
;
523 std::string
RuntimeOption::SandboxFallback
;
524 std::string
RuntimeOption::SandboxConfFile
;
525 std::map
<std::string
, std::string
> RuntimeOption::SandboxServerVariables
;
526 bool RuntimeOption::SandboxFromCommonRoot
= false;
527 std::string
RuntimeOption::SandboxDirectoriesRoot
;
528 std::string
RuntimeOption::SandboxLogsRoot
;
530 bool RuntimeOption::EnableDebugger
= false;
531 bool RuntimeOption::EnableDebuggerColor
= true;
532 bool RuntimeOption::EnableDebuggerPrompt
= true;
533 bool RuntimeOption::EnableDebuggerServer
= false;
534 bool RuntimeOption::EnableDebuggerUsageLog
= false;
535 bool RuntimeOption::DebuggerDisableIPv6
= false;
536 int RuntimeOption::DebuggerServerPort
= 8089;
537 int RuntimeOption::DebuggerDefaultRpcPort
= 8083;
538 std::string
RuntimeOption::DebuggerDefaultRpcAuth
;
539 std::string
RuntimeOption::DebuggerRpcHostDomain
;
540 int RuntimeOption::DebuggerDefaultRpcTimeout
= 30;
541 std::string
RuntimeOption::DebuggerDefaultSandboxPath
;
542 std::string
RuntimeOption::DebuggerStartupDocument
;
543 int RuntimeOption::DebuggerSignalTimeout
= 1;
545 std::string
RuntimeOption::SendmailPath
= "sendmail -t -i";
546 std::string
RuntimeOption::MailForceExtraParameters
;
548 int64_t RuntimeOption::PregBacktraceLimit
= 1000000;
549 int64_t RuntimeOption::PregRecursionLimit
= 100000;
550 bool RuntimeOption::EnablePregErrorLog
= true;
552 bool RuntimeOption::HHProfServerEnabled
= false;
553 int RuntimeOption::HHProfServerPort
= 4327;
554 int RuntimeOption::HHProfServerThreads
= 2;
555 int RuntimeOption::HHProfServerTimeoutSeconds
= 30;
556 bool RuntimeOption::HHProfServerProfileClientMode
= true;
557 bool RuntimeOption::HHProfServerAllocationProfile
= false;
558 int RuntimeOption::HHProfServerFilterMinAllocPerReq
= 2;
559 int RuntimeOption::HHProfServerFilterMinBytesPerReq
= 128;
561 bool RuntimeOption::SimpleXMLEmptyNamespaceMatchesAll
= false;
563 bool RuntimeOption::AllowDuplicateCookies
= true;
565 bool RuntimeOption::EnableHotProfiler
= true;
566 int RuntimeOption::ProfilerTraceBuffer
= 2000000;
567 double RuntimeOption::ProfilerTraceExpansion
= 1.2;
568 int RuntimeOption::ProfilerMaxTraceBuffer
= 0;
571 bool RuntimeOption::EnableFb303Server
= true;
572 int RuntimeOption::Fb303ServerPort
= 0;
573 int RuntimeOption::Fb303ServerThreadStackSizeMb
= 8;
574 int RuntimeOption::Fb303ServerWorkerThreads
= 1;
575 int RuntimeOption::Fb303ServerPoolThreads
= 1;
578 double RuntimeOption::XenonPeriodSeconds
= 0.0;
579 bool RuntimeOption::XenonForceAlwaysOn
= false;
581 std::map
<std::string
, std::string
> RuntimeOption::CustomSettings
;
583 int RuntimeOption::EnableAlternative
= 0;
587 const StaticString
s_hhvm_build_type("Release with asserts");
589 const StaticString
s_hhvm_build_type("Release");
592 const StaticString
s_hhvm_build_type("Debug");
595 ///////////////////////////////////////////////////////////////////////////////
597 static void setResourceLimit(int resource
, const IniSetting::Map
& ini
,
598 Hdf rlimit
, const char *nodeName
) {
599 if (!Config::GetString(ini
, rlimit
[nodeName
]).empty()) {
601 getrlimit(resource
, &rl
);
602 rl
.rlim_cur
= Config::GetInt64(ini
, rlimit
[nodeName
]);
603 if (rl
.rlim_max
< rl
.rlim_cur
) {
604 rl
.rlim_max
= rl
.rlim_cur
;
606 int ret
= setrlimit(resource
, &rl
);
608 Logger::Error("Unable to set %s to %" PRId64
": %s (%d)",
609 nodeName
, (int64_t)rl
.rlim_cur
,
610 folly::errnoStr(errno
).c_str(), errno
);
615 static void normalizePath(std::string
&path
) {
617 if (path
[path
.length() - 1] == '/') {
618 path
= path
.substr(0, path
.length() - 1);
620 if (path
[0] != '/') {
621 path
= std::string("/") + path
;
626 static bool matchHdfPattern(const std::string
&value
,
627 const IniSetting::Map
& ini
, Hdf hdfPattern
) {
628 string pattern
= Config::GetString(ini
, hdfPattern
);
629 if (!pattern
.empty()) {
630 Variant ret
= preg_match(String(pattern
.c_str(), pattern
.size(),
632 String(value
.c_str(), value
.size(),
634 if (ret
.toInt64() <= 0) {
641 // A machine can belong to a tier, which can overwrite
642 // various settings, even if they are set in the same
643 // hdf file. However, CLI overrides still win the day over
645 static void getTierOverwrites(IniSetting::Map
& ini
, Hdf
& config
) {
648 string hostname
, tier
, cpu
;
650 Hdf machine
= config
["Machine"];
652 hostname
= Config::GetString(ini
, machine
["name"]);
653 if (hostname
.empty()) {
654 hostname
= Process::GetHostName();
657 tier
= Config::GetString(ini
, machine
["tier"]);
659 cpu
= Config::GetString(ini
, machine
["cpu"]);
661 cpu
= Process::GetCPUModel();
667 Hdf tiers
= config
["Tiers"];
668 for (Hdf hdf
= tiers
.firstChild(); hdf
.exists(); hdf
= hdf
.next()) {
669 if (matchHdfPattern(hostname
, ini
, hdf
["machine"]) &&
670 matchHdfPattern(tier
, ini
, hdf
["tier"]) &&
671 matchHdfPattern(cpu
, ini
, hdf
["cpu"])) {
672 RuntimeOption::Tier
= hdf
.getName();
673 config
.copy(hdf
["overwrite"]);
674 // no break here, so we can continue to match more overwrites
676 hdf
["overwrite"].setVisited(); // avoid lint complaining
682 void RuntimeOption::Load(IniSetting::Map
& ini
, Hdf
& config
,
683 const std::vector
<std::string
>& iniClis
/* = std::vector<std::string>() */,
684 const std::vector
<std::string
>& hdfClis
/* = std::vector<std::string>() */) {
686 // Get the ini (-d) and hdf (-v) strings, which may override some
687 // of options that were set from config files. We also do these
688 // now so we can override Tier.*.[machine | tier | cpu] on the
689 // command line, along with any fields within a Tier (e.g.,
691 for (auto& istr
: iniClis
) {
692 Config::ParseIniString(istr
, ini
);
694 for (auto& hstr
: hdfClis
) {
695 Config::ParseHdfString(hstr
, config
, ini
);
697 // See if there are any Tier-based overrides
698 getTierOverwrites(ini
, config
);
699 // Then get the ini and hdf cli strings again, in case the tier overwrites
700 // overrode any non-tier based command line option we set. The tier-based
701 // command line overwrites will already have been set in the call above.
702 // This extra call is for the other command line options that may have been
703 // overridden by a tier, but shouldn't have been.
704 for (auto& istr
: iniClis
) {
705 Config::ParseIniString(istr
, ini
);
707 for (auto& hstr
: hdfClis
) {
708 Config::ParseHdfString(hstr
, config
, ini
);
711 Config::Bind(PidFile
, ini
, config
["PidFile"], "www.pid");
713 Config::Get(ini
, config
["DynamicInvokeFunctions"], DynamicInvokeFunctions
);
716 Hdf logger
= config
["Log"];
717 if (logger
["Level"] == "None") {
718 Logger::LogLevel
= Logger::LogNone
;
719 } else if (logger
["Level"] == "Error") {
720 Logger::LogLevel
= Logger::LogError
;
721 } else if (logger
["Level"] == "Warning") {
722 Logger::LogLevel
= Logger::LogWarning
;
723 } else if (logger
["Level"] == "Info") {
724 Logger::LogLevel
= Logger::LogInfo
;
725 } else if (logger
["Level"] == "Verbose") {
726 Logger::LogLevel
= Logger::LogVerbose
;
728 IniSetting::Bind(IniSetting::CORE
, IniSetting::PHP_INI_SYSTEM
,
729 "hhvm.log.level", IniSetting::SetAndGet
<std::string
>(
730 [](const std::string
& value
) {
731 if (value
== "None") {
732 Logger::LogLevel
= Logger::LogNone
;
733 } else if (value
== "Error") {
734 Logger::LogLevel
= Logger::LogError
;
735 } else if (value
== "Warning") {
736 Logger::LogLevel
= Logger::LogWarning
;
737 } else if (value
== "Info") {
738 Logger::LogLevel
= Logger::LogInfo
;
739 } else if (value
== "Verbose") {
740 Logger::LogLevel
= Logger::LogVerbose
;
747 switch (Logger::LogLevel
) {
748 case Logger::LogNone
:
750 case Logger::LogError
:
752 case Logger::LogWarning
:
754 case Logger::LogInfo
:
756 case Logger::LogVerbose
:
763 Config::Bind(Logger::LogHeader
, ini
, logger
["Header"]);
764 Config::Bind(Logger::LogNativeStackTrace
, ini
, logger
["NativeStackTrace"],
766 Config::Bind(Logger::MaxMessagesPerRequest
, ini
,
767 logger
["MaxMessagesPerRequest"], -1);
769 Config::Bind(Logger::UseSyslog
, ini
, logger
["UseSyslog"], false);
770 Config::Bind(Logger::UseLogFile
, ini
, logger
["UseLogFile"], true);
771 Config::Bind(Logger::UseCronolog
, ini
, logger
["UseCronolog"], false);
772 Config::Bind(Logger::UseRequestLog
, ini
, logger
["UseRequestLog"], false);
773 if (Logger::UseLogFile
) {
774 Config::Bind(LogFile
, ini
, logger
["File"]);
775 if (!RuntimeOption::ServerExecutionMode()) {
778 if (LogFile
[0] == '|') Logger::IsPipeOutput
= true;
779 Config::Bind(LogFileSymLink
, ini
, logger
["SymLink"]);
781 Config::Bind(LogFileFlusher::DropCacheChunkSize
, ini
,
782 logger
["DropCacheChunkSize"], 1 << 20);
783 Config::Bind(AlwaysEscapeLog
, ini
, logger
["AlwaysEscapeLog"], false);
784 Config::Bind(RuntimeOption::LogHeaderMangle
, ini
, logger
["HeaderMangle"],
787 Config::Bind(AlwaysLogUnhandledExceptions
, ini
,
788 logger
["AlwaysLogUnhandledExceptions"], true);
789 Config::Bind(NoSilencer
, ini
, logger
["NoSilencer"]);
790 Config::Bind(RuntimeErrorReportingLevel
, ini
,
791 logger
["RuntimeErrorReportingLevel"],
792 static_cast<int>(ErrorConstants::ErrorModes::HPHP_ALL
));
793 Config::Bind(ForceErrorReportingLevel
, ini
,
794 logger
["ForceErrorReportingLevel"], 0);
795 Config::Bind(AccessLogDefaultFormat
, ini
, logger
["AccessLogDefaultFormat"],
796 "%h %l %u %t \"%r\" %>s %b");
799 Hdf access
= logger
["Access"];
800 for (Hdf hdf
= access
.firstChild(); hdf
.exists();
802 string fname
= Config::GetString(ini
, hdf
["File"]);
806 string symLink
= Config::GetString(ini
, hdf
["SymLink"]);
807 AccessLogs
.push_back(AccessLogFileData(fname
, symLink
,
808 Config::GetString(ini
, hdf
["Format"], AccessLogDefaultFormat
)));
812 Config::Bind(AdminLogFormat
, ini
, logger
["AdminLog.Format"], "%h %t %s %U");
813 Config::Bind(AdminLogFile
, ini
, logger
["AdminLog.File"]);
814 Config::Bind(AdminLogSymLink
, ini
, logger
["AdminLog.SymLink"]);
817 Hdf error
= config
["ErrorHandling"];
819 /* Remove this, once its removed from production configs */
820 (void)Config::GetBool(ini
, error
["NoInfiniteLoopDetection"]);
822 Config::Bind(ErrorUpgradeLevel
, ini
, error
["UpgradeLevel"], 0);
823 Config::Bind(MaxSerializedStringSize
, ini
,
824 error
["MaxSerializedStringSize"], 64 * 1024 * 1024);
825 Config::Bind(CallUserHandlerOnFatals
, ini
,
826 error
["CallUserHandlerOnFatals"], true);
827 Config::Bind(ThrowExceptionOnBadMethodCall
, ini
,
828 error
["ThrowExceptionOnBadMethodCall"], true);
829 Config::Bind(LogNativeStackOnOOM
, ini
,
830 error
["LogNativeStackOnOOM"], false);
831 Config::Bind(MaxLoopCount
, ini
, error
["MaxLoopCount"], 0);
832 Config::Bind(NoInfiniteRecursionDetection
, ini
,
833 error
["NoInfiniteRecursionDetection"]);
834 Config::Bind(WarnTooManyArguments
, ini
, error
["WarnTooManyArguments"]);
835 Config::Bind(EnableHipHopErrors
, ini
, error
["EnableHipHopErrors"], true);
836 Config::Bind(AssertActive
, ini
, error
["AssertActive"]);
837 Config::Bind(AssertWarning
, ini
, error
["AssertWarning"]);
838 Config::Bind(NoticeFrequency
, ini
, error
["NoticeFrequency"], 1);
839 Config::Bind(WarningFrequency
, ini
, error
["WarningFrequency"], 1);
842 Hdf rlimit
= config
["ResourceLimit"];
843 if (Config::GetInt64(ini
, rlimit
["CoreFileSizeOverride"])) {
844 setResourceLimit(RLIMIT_CORE
, ini
, rlimit
, "CoreFileSizeOverride");
846 setResourceLimit(RLIMIT_CORE
, ini
, rlimit
, "CoreFileSize");
848 setResourceLimit(RLIMIT_NOFILE
, ini
, rlimit
, "MaxSocket");
849 setResourceLimit(RLIMIT_DATA
, ini
, rlimit
, "RSS");
850 // These don't have RuntimeOption::xxx bindings, but we still want to be
851 // able to use ini_xxx functionality on them; so directly bind to a local
852 // static via Config::Bind.
853 static int64_t s_core_file_size_override
, s_core_file_size
, s_rss
= 0;
854 static int32_t s_max_socket
= 0;
855 Config::Bind(s_core_file_size_override
, ini
, rlimit
["CoreFileSizeOverride"],
857 Config::Bind(s_core_file_size
, ini
, rlimit
["CoreFileSize"], 0);
858 Config::Bind(s_max_socket
, ini
, rlimit
["MaxSocket"], 0);
859 Config::Bind(s_rss
, ini
, rlimit
["RSS"], 0);
861 Config::Bind(MaxRSS
, ini
, rlimit
["MaxRSS"], 0);
862 Config::Bind(SocketDefaultTimeout
, ini
, rlimit
["SocketDefaultTimeout"], 5);
863 Config::Bind(MaxRSSPollingCycle
, ini
, rlimit
["MaxRSSPollingCycle"], 0);
864 Config::Bind(DropCacheCycle
, ini
, rlimit
["DropCacheCycle"], 0);
865 Config::Bind(MaxSQLRowCount
, ini
, rlimit
["MaxSQLRowCount"], 0);
866 Config::Bind(MaxMemcacheKeyCount
, ini
, rlimit
["MaxMemcacheKeyCount"], 0);
867 Config::Bind(SerializationSizeLimit
, ini
, rlimit
["SerializationSizeLimit"],
868 StringData::MaxSize
);
869 Config::Bind(StringOffsetLimit
, ini
, rlimit
["StringOffsetLimit"],
873 Hdf eval
= config
["Eval"];
874 Config::Bind(EnableHipHopSyntax
, ini
, eval
["EnableHipHopSyntax"]);
875 Config::Bind(EnableHipHopExperimentalSyntax
, ini
,
876 eval
["EnableHipHopExperimentalSyntax"]);
877 Config::Bind(EnableShortTags
, ini
, eval
["EnableShortTags"], true);
878 Config::Bind(EnableAspTags
, ini
, eval
["EnableAspTags"]);
879 Config::Bind(EnableXHP
, ini
, eval
["EnableXHP"], false);
880 Config::Bind(EnableZendCompat
, ini
, eval
["EnableZendCompat"], false);
881 Config::Bind(EnableZendSorting
, ini
, eval
["EnableZendSorting"], false);
882 Config::Bind(TimeoutsUseWallTime
, ini
, eval
["TimeoutsUseWallTime"], true);
883 Config::Bind(CheckFlushOnUserClose
, ini
, eval
["CheckFlushOnUserClose"],
886 if (EnableHipHopSyntax
) {
887 // If EnableHipHopSyntax is true, it forces EnableXHP to true
888 // regardless of how it was set in the config
892 Config::Bind(EnableObjDestructCall
, ini
, eval
["EnableObjDestructCall"],
894 Config::Bind(MaxUserFunctionId
, ini
, eval
["MaxUserFunctionId"], 2 * 65536);
895 Config::Bind(CheckSymLink
, ini
, eval
["CheckSymLink"], true);
897 Config::Bind(EnableAlternative
, ini
, eval
["EnableAlternative"], 0);
898 #define F(type, name, defaultVal) \
899 Config::Bind(Eval ## name, ini, eval[#name], defaultVal);
902 low_malloc_huge_pages(EvalMaxLowMemHugePages
);
903 Config::Bind(EnableEmitSwitch
, ini
, eval
["EnableEmitSwitch"], true);
904 Config::Bind(EnableEmitterStats
, ini
, eval
["EnableEmitterStats"],
906 Config::Bind(RecordCodeCoverage
, ini
, eval
["RecordCodeCoverage"]);
907 if (EvalJit
&& RecordCodeCoverage
) {
908 throw std::runtime_error("Code coverage is not supported with "
911 if (RecordCodeCoverage
) CheckSymLink
= true;
912 Config::Bind(CodeCoverageOutputFile
, ini
, eval
["CodeCoverageOutputFile"]);
914 Hdf debugger
= eval
["Debugger"];
915 Config::Bind(EnableDebugger
, ini
, debugger
["EnableDebugger"]);
916 Config::Bind(EnableDebuggerColor
, ini
, debugger
["EnableDebuggerColor"],
918 Config::Bind(EnableDebuggerPrompt
, ini
, debugger
["EnableDebuggerPrompt"],
920 Config::Bind(EnableDebuggerServer
, ini
, debugger
["EnableDebuggerServer"]);
921 Config::Bind(EnableDebuggerUsageLog
, ini
,
922 debugger
["EnableDebuggerUsageLog"]);
923 Config::Bind(DebuggerServerPort
, ini
, debugger
["Port"], 8089);
924 Config::Bind(DebuggerDisableIPv6
, ini
, debugger
["DisableIPv6"], false);
925 Config::Bind(DebuggerDefaultSandboxPath
, ini
,
926 debugger
["DefaultSandboxPath"]);
927 Config::Bind(DebuggerStartupDocument
, ini
, debugger
["StartupDocument"]);
928 Config::Bind(DebuggerSignalTimeout
, ini
, debugger
["SignalTimeout"], 1);
930 Config::Bind(DebuggerDefaultRpcPort
, ini
, debugger
["RPC.DefaultPort"],
932 Config::Bind(DebuggerDefaultRpcAuth
, ini
, debugger
["RPC.DefaultAuth"]);
933 Config::Bind(DebuggerRpcHostDomain
, ini
, debugger
["RPC.HostDomain"]);
934 Config::Bind(DebuggerDefaultRpcTimeout
, ini
,
935 debugger
["RPC.DefaultTimeout"], 30);
938 Hdf lang
= config
["Hack"]["Lang"];
939 Config::Bind(IntsOverflowToInts
, ini
, lang
["IntsOverflowToInts"],
941 Config::Bind(StrictArrayFillKeys
, ini
, lang
["StrictArrayFillKeys"]);
942 Config::Bind(DisallowDynamicVarEnvFuncs
, ini
,
943 lang
["DisallowDynamicVarEnvFuncs"]);
944 // Defaults to EnableHHSyntax since, if you have that on, you are
945 // assumed to know what you're doing.
946 Config::Bind(LookForTypechecker
, ini
, lang
["LookForTypechecker"],
947 !EnableHipHopSyntax
);
950 Hdf repo
= config
["Repo"];
952 Hdf repoLocal
= repo
["Local"];
954 Config::Bind(RepoLocalMode
, ini
, repoLocal
["Mode"]);
955 if (RepoLocalMode
.empty()) {
956 const char* HHVM_REPO_LOCAL_MODE
= getenv("HHVM_REPO_LOCAL_MODE");
957 if (HHVM_REPO_LOCAL_MODE
!= nullptr) {
958 RepoLocalMode
= HHVM_REPO_LOCAL_MODE
;
960 RepoLocalMode
= "r-";
962 if (RepoLocalMode
.compare("rw")
963 && RepoLocalMode
.compare("r-")
964 && RepoLocalMode
.compare("--")) {
965 Logger::Error("Bad config setting: Repo.Local.Mode=%s",
966 RepoLocalMode
.c_str());
967 RepoLocalMode
= "rw";
970 Config::Bind(RepoLocalPath
, ini
, repoLocal
["Path"]);
971 if (RepoLocalPath
.empty()) {
972 const char* HHVM_REPO_LOCAL_PATH
= getenv("HHVM_REPO_LOCAL_PATH");
973 if (HHVM_REPO_LOCAL_PATH
!= nullptr) {
974 RepoLocalPath
= HHVM_REPO_LOCAL_PATH
;
979 Hdf repoCentral
= repo
["Central"];
980 // Repo.Central.Path.
981 Config::Bind(RepoCentralPath
, ini
, repoCentral
["Path"]);
984 Hdf repoEval
= repo
["Eval"];
986 Config::Bind(RepoEvalMode
, ini
, repoEval
["Mode"]);
987 if (RepoEvalMode
.empty()) {
988 RepoEvalMode
= "readonly";
989 } else if (RepoEvalMode
.compare("local")
990 && RepoEvalMode
.compare("central")
991 && RepoEvalMode
.compare("readonly")) {
992 Logger::Error("Bad config setting: Repo.Eval.Mode=%s",
993 RepoEvalMode
.c_str());
994 RepoEvalMode
= "readonly";
997 Config::Bind(RepoJournal
, ini
, repo
["Journal"], "delete");
998 Config::Bind(RepoCommit
, ini
, repo
["Commit"], true);
999 Config::Bind(RepoDebugInfo
, ini
, repo
["DebugInfo"], true);
1000 Config::Bind(RepoAuthoritative
, ini
, repo
["Authoritative"], false);
1001 Config::Bind(RepoPreload
, ini
, repo
["Preload"], RepoAuthoritative
);
1004 // NB: after we know the value of RepoAuthoritative.
1005 Config::Bind(EnableArgsInBacktraces
, ini
, eval
["EnableArgsInBacktraces"],
1006 !RepoAuthoritative
);
1007 Config::Bind(EvalAuthoritativeMode
, ini
, eval
["AuthoritativeMode"], false);
1008 if (RepoAuthoritative
) {
1009 EvalAuthoritativeMode
= true;
1013 Hdf server
= config
["Server"];
1014 Config::Bind(Host
, ini
, server
["Host"]);
1015 Config::Bind(DefaultServerNameSuffix
, ini
,
1016 server
["DefaultServerNameSuffix"]);
1017 Config::Bind(ServerType
, ini
, server
["Type"], ServerType
);
1018 Config::Bind(ServerIP
, ini
, server
["IP"]);
1019 Config::Bind(ServerFileSocket
, ini
, server
["FileSocket"]);
1020 ServerPrimaryIP
= GetPrimaryIP();
1021 Config::Bind(ServerPort
, ini
, server
["Port"], 80);
1022 Config::Bind(ServerBacklog
, ini
, server
["Backlog"], 128);
1023 Config::Bind(ServerConnectionLimit
, ini
, server
["ConnectionLimit"], 0);
1024 Config::Bind(ServerThreadCount
, ini
, server
["ThreadCount"],
1025 Process::GetCPUCount() * 2);
1027 Config::Bind(ProdServerPort
, ini
,
1028 server
["ProdServerPort"], 80);
1030 Config::Bind(ServerThreadRoundRobin
, ini
, server
["ThreadRoundRobin"]);
1031 Config::Bind(ServerWarmupThrottleRequestCount
, ini
,
1032 server
["WarmupThrottleRequestCount"],
1033 ServerWarmupThrottleRequestCount
);
1034 Config::Bind(ServerThreadDropCacheTimeoutSeconds
, ini
,
1035 server
["ThreadDropCacheTimeoutSeconds"], 0);
1036 if (Config::GetBool(ini
, server
["ThreadJobLIFO"])) {
1037 ServerThreadJobLIFOSwitchThreshold
= 0;
1039 Config::Bind(ServerThreadJobLIFOSwitchThreshold
, ini
,
1040 server
["ThreadJobLIFOSwitchThreshold"],
1041 ServerThreadJobLIFOSwitchThreshold
);
1042 Config::Bind(ServerThreadJobMaxQueuingMilliSeconds
, ini
,
1043 server
["ThreadJobMaxQueuingMilliSeconds"], -1);
1044 Config::Bind(ServerThreadDropStack
, ini
, server
["ThreadDropStack"]);
1045 Config::Bind(ServerHttpSafeMode
, ini
, server
["HttpSafeMode"]);
1046 Config::Bind(ServerStatCache
, ini
, server
["StatCache"], false);
1047 Config::Bind(ServerFixPathInfo
, ini
, server
["FixPathInfo"], false);
1048 Config::Get(ini
, server
["WarmupRequests"], ServerWarmupRequests
);
1049 Config::Get(ini
, server
["HighPriorityEndPoints"],
1050 ServerHighPriorityEndPoints
);
1051 Config::Bind(ServerExitOnBindFail
, ini
, server
["ExitOnBindFail"], false);
1053 Config::Bind(RequestTimeoutSeconds
, ini
, server
["RequestTimeoutSeconds"],
1055 Config::Bind(MaxRequestAgeFactor
, ini
, server
["MaxRequestAgeFactor"], 0);
1056 Config::Bind(PspTimeoutSeconds
, ini
, server
["PspTimeoutSeconds"], 0);
1057 Config::Bind(ServerMemoryHeadRoom
, ini
, server
["MemoryHeadRoom"], 0);
1058 Config::Bind(RequestMemoryMaxBytes
, ini
, server
["RequestMemoryMaxBytes"],
1059 std::numeric_limits
<int64_t>::max());
1060 Config::Bind(ResponseQueueCount
, ini
, server
["ResponseQueueCount"], 0);
1061 if (ResponseQueueCount
<= 0) {
1062 ResponseQueueCount
= ServerThreadCount
/ 10;
1063 if (ResponseQueueCount
<= 0) ResponseQueueCount
= 1;
1065 Config::Bind(ServerGracefulShutdownWait
, ini
,
1066 server
["GracefulShutdownWait"], 0);
1067 Config::Bind(ServerHarshShutdown
, ini
, server
["HarshShutdown"], true);
1068 Config::Bind(ServerKillOnSIGTERM
, ini
, server
["KillOnSIGTERM"], false);
1069 Config::Bind(ServerEvilShutdown
, ini
, server
["EvilShutdown"], true);
1070 Config::Bind(ServerDanglingWait
, ini
, server
["DanglingWait"], 0);
1071 Config::Bind(ServerShutdownListenWait
, ini
, server
["ShutdownListenWait"],
1073 Config::Bind(ServerShutdownListenNoWork
, ini
,
1074 server
["ShutdownListenNoWork"], -1);
1075 Config::Get(ini
, server
["SSLNextProtocols"], ServerNextProtocols
);
1076 if (ServerGracefulShutdownWait
< ServerDanglingWait
) {
1077 ServerGracefulShutdownWait
= ServerDanglingWait
;
1079 Config::Bind(GzipCompressionLevel
, ini
, server
["GzipCompressionLevel"], 3);
1080 Config::Bind(GzipMaxCompressionLevel
, ini
,
1081 server
["GzipMaxCompressionLevel"], 9);
1083 Config::Bind(ForceCompressionURL
, ini
, server
["ForceCompression"]["URL"]);
1084 Config::Bind(ForceCompressionCookie
, ini
,
1085 server
["ForceCompression"]["Cookie"]);
1086 Config::Bind(ForceCompressionParam
, ini
,
1087 server
["ForceCompression"]["Param"]);
1089 Config::Bind(EnableMagicQuotesGpc
, ini
, server
["EnableMagicQuotesGpc"]);
1090 Config::Bind(EnableKeepAlive
, ini
, server
["EnableKeepAlive"], true);
1091 Config::Bind(ExposeHPHP
, ini
, server
["ExposeHPHP"], true);
1092 Config::Bind(ExposeXFBServer
, ini
, server
["ExposeXFBServer"], false);
1093 Config::Bind(ExposeXFBDebug
, ini
, server
["ExposeXFBDebug"], false);
1094 Config::Bind(XFBDebugSSLKey
, ini
, server
["XFBDebugSSLKey"], "");
1095 Config::Bind(ConnectionTimeoutSeconds
, ini
,
1096 server
["ConnectionTimeoutSeconds"], -1);
1097 Config::Bind(EnableOutputBuffering
, ini
, server
["EnableOutputBuffering"]);
1098 Config::Bind(OutputHandler
, ini
, server
["OutputHandler"]);
1099 Config::Bind(ImplicitFlush
, ini
, server
["ImplicitFlush"]);
1100 Config::Bind(EnableEarlyFlush
, ini
, server
["EnableEarlyFlush"], true);
1101 Config::Bind(ForceChunkedEncoding
, ini
, server
["ForceChunkedEncoding"]);
1102 Config::Bind(MaxPostSize
, ini
, server
["MaxPostSize"], 100);
1104 Config::Bind(AlwaysPopulateRawPostData
, ini
,
1105 server
["AlwaysPopulateRawPostData"], true);
1106 Config::Bind(LibEventSyncSend
, ini
, server
["LibEventSyncSend"], true);
1107 Config::Bind(TakeoverFilename
, ini
, server
["TakeoverFilename"]);
1108 Config::Bind(ExpiresActive
, ini
, server
["ExpiresActive"], true);
1109 Config::Bind(ExpiresDefault
, ini
, server
["ExpiresDefault"], 2592000);
1110 if (ExpiresDefault
< 0) ExpiresDefault
= 2592000;
1111 Config::Bind(DefaultCharsetName
, ini
, server
["DefaultCharsetName"],
1114 Config::Bind(RequestBodyReadLimit
, ini
, server
["RequestBodyReadLimit"], -1);
1116 Config::Bind(EnableSSL
, ini
, server
["EnableSSL"]);
1117 Config::Bind(SSLPort
, ini
, server
["SSLPort"], 443);
1118 Config::Bind(SSLCertificateFile
, ini
, server
["SSLCertificateFile"]);
1119 Config::Bind(SSLCertificateKeyFile
, ini
, server
["SSLCertificateKeyFile"]);
1120 Config::Bind(SSLCertificateDir
, ini
, server
["SSLCertificateDir"]);
1121 Config::Bind(TLSDisableTLS1_2
, ini
, server
["TLSDisableTLS1_2"], false);
1122 Config::Bind(TLSClientCipherSpec
, ini
, server
["TLSClientCipherSpec"]);
1124 string srcRoot
= FileUtil::normalizeDir(
1125 Config::GetString(ini
, server
["SourceRoot"]));
1126 if (!srcRoot
.empty()) SourceRoot
= srcRoot
;
1127 FileCache::SourceRoot
= SourceRoot
;
1129 Config::Get(ini
, server
["IncludeSearchPaths"], IncludeSearchPaths
);
1130 for (unsigned int i
= 0; i
< IncludeSearchPaths
.size(); i
++) {
1131 IncludeSearchPaths
[i
] = FileUtil::normalizeDir(IncludeSearchPaths
[i
]);
1133 IncludeSearchPaths
.insert(IncludeSearchPaths
.begin(), ".");
1135 Config::Bind(FileCache
, ini
, server
["FileCache"]);
1136 Config::Bind(DefaultDocument
, ini
, server
["DefaultDocument"]);
1137 Config::Bind(ErrorDocument404
, ini
, server
["ErrorDocument404"]);
1138 normalizePath(ErrorDocument404
);
1139 Config::Bind(ForbiddenAs404
, ini
, server
["ForbiddenAs404"]);
1140 Config::Bind(ErrorDocument500
, ini
, server
["ErrorDocument500"]);
1141 normalizePath(ErrorDocument500
);
1142 Config::Bind(FatalErrorMessage
, ini
, server
["FatalErrorMessage"]);
1143 FontPath
= FileUtil::normalizeDir(
1144 Config::GetString(ini
, server
["FontPath"]));
1145 Config::Bind(EnableStaticContentFromDisk
, ini
,
1146 server
["EnableStaticContentFromDisk"], true);
1147 Config::Bind(EnableOnDemandUncompress
, ini
,
1148 server
["EnableOnDemandUncompress"], true);
1149 Config::Bind(EnableStaticContentMMap
, ini
,
1150 server
["EnableStaticContentMMap"], true);
1151 if (EnableStaticContentMMap
) {
1152 EnableOnDemandUncompress
= true;
1154 Config::Bind(Utf8izeReplace
, ini
, server
["Utf8izeReplace"], true);
1156 Config::Bind(StartupDocument
, ini
, server
["StartupDocument"]);
1157 normalizePath(StartupDocument
);
1158 Config::Bind(WarmupDocument
, ini
, server
["WarmupDocument"]);
1159 Config::Bind(RequestInitFunction
, ini
, server
["RequestInitFunction"]);
1160 Config::Bind(RequestInitDocument
, ini
, server
["RequestInitDocument"]);
1162 Config::Bind(SafeFileAccess
, ini
, server
["SafeFileAccess"]);
1163 Config::Get(ini
, server
["AllowedDirectories"], AllowedDirectories
);
1165 Config::Bind(WhitelistExec
, ini
, server
["WhitelistExec"]);
1166 Config::Bind(WhitelistExecWarningOnly
, ini
,
1167 server
["WhitelistExecWarningOnly"]);
1168 Config::Bind(AllowedExecCmds
, ini
, server
["AllowedExecCmds"]);
1169 Config::Bind(UnserializationWhitelistCheck
, ini
,
1170 server
["UnserializationWhitelistCheck"], false);
1171 Config::Bind(UnserializationWhitelistCheckWarningOnly
, ini
,
1172 server
["UnserializationWhitelistCheckWarningOnly"], true);
1174 Config::Get(ini
, server
["AllowedFiles"], AllowedFiles
);
1176 Config::Get(ini
, server
["ForbiddenFileExtensions"],
1177 ForbiddenFileExtensions
);
1179 Config::Bind(LockCodeMemory
, ini
, server
["LockCodeMemory"], false);
1180 Config::Bind(MaxArrayChain
, ini
, server
["MaxArrayChain"], INT_MAX
);
1181 if (MaxArrayChain
!= INT_MAX
) {
1182 // MixedArray needs a higher threshold to avoid false-positives.
1183 // (and we always use MixedArray)
1187 Config::Bind(WarnOnCollectionToArray
, ini
,
1188 server
["WarnOnCollectionToArray"], false);
1189 Config::Bind(UseDirectCopy
, ini
, server
["UseDirectCopy"], false);
1190 Config::Bind(AlwaysUseRelativePath
, ini
, server
["AlwaysUseRelativePath"],
1193 Hdf upload
= server
["Upload"];
1194 Config::Bind(UploadMaxFileSize
, ini
, upload
["UploadMaxFileSize"], 100);
1195 UploadMaxFileSize
<<= 20;
1197 Config::Bind(UploadTmpDir
, ini
, upload
["UploadTmpDir"], "/tmp");
1198 Config::Bind(EnableFileUploads
, ini
, upload
["EnableFileUploads"], true);
1199 Config::Bind(MaxFileUploads
, ini
, "max_file_uploads", 20);
1200 Config::Bind(EnableUploadProgress
, ini
, upload
["EnableUploadProgress"]);
1201 Config::Bind(Rfc1867Freq
, ini
, upload
["Rfc1867Freq"], 256 * 1024);
1202 if (Rfc1867Freq
< 0) Rfc1867Freq
= 256 * 1024;
1203 Config::Bind(Rfc1867Prefix
, ini
, upload
["Rfc1867Prefix"], "vupload_");
1204 Config::Bind(Rfc1867Name
, ini
, upload
["Rfc1867Name"], "video_ptoken");
1206 Config::Bind(ImageMemoryMaxBytes
, ini
, server
["ImageMemoryMaxBytes"], 0);
1207 if (ImageMemoryMaxBytes
== 0) {
1208 ImageMemoryMaxBytes
= UploadMaxFileSize
* 2;
1211 Config::Bind(LightProcessFilePrefix
, ini
, server
["LightProcessFilePrefix"],
1213 Config::Bind(LightProcessCount
, ini
, server
["LightProcessCount"], 0);
1215 Config::Bind(ForceServerNameToHeader
, ini
,
1216 server
["ForceServerNameToHeader"]);
1218 Config::Bind(AllowDuplicateCookies
, ini
, server
["AllowDuplicateCookies"],
1219 !EnableHipHopSyntax
);
1221 Config::Bind(EnableCufAsync
, ini
, server
["EnableCufAsync"], false);
1222 Config::Bind(PathDebug
, ini
, server
["PathDebug"], false);
1224 Config::Bind(ServerUser
, ini
, server
["User"], "");
1227 VirtualHost::SortAllowedDirectories(AllowedDirectories
);
1229 Hdf hosts
= config
["VirtualHost"];
1230 if (hosts
.exists()) {
1231 for (Hdf hdf
= hosts
.firstChild(); hdf
.exists(); hdf
= hdf
.next()) {
1232 if (hdf
.getName() == "default") {
1233 VirtualHost::GetDefault().init(ini
, hdf
);
1234 VirtualHost::GetDefault().addAllowedDirectories(AllowedDirectories
);
1236 auto host
= std::make_shared
<VirtualHost
>(ini
, hdf
);
1237 host
->addAllowedDirectories(AllowedDirectories
);
1238 VirtualHosts
.push_back(host
);
1241 for (unsigned int i
= 0; i
< VirtualHosts
.size(); i
++) {
1242 if (!VirtualHosts
[i
]->valid()) {
1243 throw std::runtime_error("virtual host missing prefix or pattern");
1249 Hdf ipblocks
= config
["IpBlockMap"];
1250 IpBlocks
= std::make_shared
<IpBlockMap
>(ini
, ipblocks
);
1253 Hdf satellites
= config
["Satellites"];
1254 if (satellites
.exists()) {
1255 for (Hdf hdf
= satellites
.firstChild(); hdf
.exists(); hdf
= hdf
.next()) {
1256 auto satellite
= std::make_shared
<SatelliteServerInfo
>(ini
, hdf
);
1257 SatelliteServerInfos
.push_back(satellite
);
1258 if (satellite
->getType() == SatelliteServer::Type::KindOfRPCServer
) {
1259 XboxPassword
= satellite
->getPassword();
1260 XboxPasswords
= satellite
->getPasswords();
1266 Hdf xbox
= config
["Xbox"];
1267 Config::Bind(XboxServerThreadCount
, ini
, xbox
["ServerInfo.ThreadCount"],
1269 Config::Bind(XboxServerMaxQueueLength
, ini
,
1270 xbox
["ServerInfo.MaxQueueLength"], INT_MAX
);
1271 if (XboxServerMaxQueueLength
< 0) XboxServerMaxQueueLength
= INT_MAX
;
1272 Config::Bind(XboxServerPort
, ini
, xbox
["ServerInfo.Port"], 0);
1273 Config::Bind(XboxDefaultLocalTimeoutMilliSeconds
, ini
,
1274 xbox
["DefaultLocalTimeoutMilliSeconds"], 500);
1275 Config::Bind(XboxDefaultRemoteTimeoutSeconds
, ini
,
1276 xbox
["DefaultRemoteTimeoutSeconds"], 5);
1277 Config::Bind(XboxServerInfoMaxRequest
, ini
, xbox
["ServerInfo.MaxRequest"],
1279 Config::Bind(XboxServerInfoDuration
, ini
, xbox
["ServerInfo.MaxDuration"],
1281 Config::Bind(XboxServerInfoWarmupDoc
, ini
,
1282 xbox
["ServerInfo.WarmupDocument"], "");
1283 Config::Bind(XboxServerInfoReqInitFunc
, ini
,
1284 xbox
["ServerInfo.RequestInitFunction"], "");
1285 Config::Bind(XboxServerInfoReqInitDoc
, ini
,
1286 xbox
["ServerInfo.RequestInitDocument"], "");
1287 Config::Bind(XboxServerInfoAlwaysReset
, ini
,
1288 xbox
["ServerInfo.AlwaysReset"], false);
1289 Config::Bind(XboxServerLogInfo
, ini
, xbox
["ServerInfo.LogInfo"], false);
1290 Config::Bind(XboxProcessMessageFunc
, ini
, xbox
["ProcessMessageFunc"],
1291 "xbox_process_message");
1294 Hdf pagelet
= config
["PageletServer"];
1295 Config::Bind(PageletServerThreadCount
, ini
, pagelet
["ThreadCount"], 0);
1296 Config::Bind(PageletServerThreadRoundRobin
, ini
,
1297 pagelet
["ThreadRoundRobin"]);
1298 Config::Bind(PageletServerThreadDropStack
, ini
, pagelet
["ThreadDropStack"]);
1299 Config::Bind(PageletServerThreadDropCacheTimeoutSeconds
, ini
,
1300 pagelet
["ThreadDropCacheTimeoutSeconds"], 0);
1301 Config::Bind(PageletServerQueueLimit
, ini
, pagelet
["QueueLimit"], 0);
1304 Hdf content
= config
["StaticFile"];
1305 Config::Get(ini
, content
["Extensions"], StaticFileExtensions
);
1306 Config::Get(ini
, content
["Generators"], StaticFileGenerators
);
1308 Hdf matches
= content
["FilesMatch"];
1309 if (matches
.exists()) {
1310 for (Hdf hdf
= matches
.firstChild(); hdf
.exists(); hdf
= hdf
.next()) {
1311 FilesMatches
.push_back(std::make_shared
<FilesMatch
>(ini
, hdf
));
1316 Hdf phpfile
= config
["PhpFile"];
1317 Config::Get(ini
, phpfile
["Extensions"], PhpFileExtensions
);
1320 Hdf admin
= config
["AdminServer"];
1321 Config::Bind(AdminServerPort
, ini
, admin
["Port"], 0);
1322 Config::Bind(AdminThreadCount
, ini
, admin
["ThreadCount"], 1);
1323 Config::Bind(AdminPassword
, ini
, admin
["Password"]);
1324 Config::Get(ini
, admin
["Passwords"], AdminPasswords
);
1327 Hdf proxy
= config
["Proxy"];
1328 Config::Bind(ProxyOrigin
, ini
, proxy
["Origin"]);
1329 Config::Bind(ProxyRetry
, ini
, proxy
["Retry"], 3);
1330 Config::Bind(UseServeURLs
, ini
, proxy
["ServeURLs"]);
1331 Config::Get(ini
, proxy
["ServeURLs"], ServeURLs
);
1332 Config::Bind(UseProxyURLs
, ini
, proxy
["ProxyURLs"]);
1333 Config::Bind(ProxyPercentage
, ini
, proxy
["Percentage"], 0);
1334 Config::Get(ini
, proxy
["ProxyURLs"], ProxyURLs
);
1335 Config::Get(ini
, proxy
["ProxyPatterns"], ProxyPatterns
);
1338 Hdf http
= config
["Http"];
1339 Config::Bind(HttpDefaultTimeout
, ini
, http
["DefaultTimeout"], 30);
1340 Config::Bind(HttpSlowQueryThreshold
, ini
, http
["SlowQueryThreshold"], 5000);
1343 Hdf debug
= config
["Debug"];
1344 Config::Bind(NativeStackTrace
, ini
, debug
["NativeStackTrace"]);
1345 StackTrace::Enabled
= NativeStackTrace
;
1346 Config::Bind(TranslateLeakStackTrace
, ini
,
1347 debug
["TranslateLeakStackTrace"]);
1348 Config::Bind(FullBacktrace
, ini
, debug
["FullBacktrace"]);
1349 Config::Bind(ServerErrorMessage
, ini
, debug
["ServerErrorMessage"]);
1350 Config::Bind(TranslateSource
, ini
, debug
["TranslateSource"]);
1351 Config::Bind(RecordInput
, ini
, debug
["RecordInput"]);
1352 Config::Bind(ClearInputOnSuccess
, ini
, debug
["ClearInputOnSuccess"], true);
1353 Config::Bind(ProfilerOutputDir
, ini
, debug
["ProfilerOutputDir"], "/tmp");
1354 Config::Bind(CoreDumpEmail
, ini
, debug
["CoreDumpEmail"]);
1355 Config::Bind(CoreDumpReport
, ini
, debug
["CoreDumpReport"], true);
1356 if (CoreDumpReport
) {
1357 install_crash_reporter();
1360 auto core_dump_report_dir
=
1361 Config::Get(ini
, debug
["CoreDumpReportDirectory"],
1362 #if defined(HPHP_OSS)
1368 std::ostringstream stack_trace_stream
;
1369 stack_trace_stream
<< core_dump_report_dir
<< "/stacktrace."
1370 << Process::GetProcessId() << ".log";
1371 StackTraceFilename
= stack_trace_stream
.str();
1373 Config::Bind(LocalMemcache
, ini
, debug
["LocalMemcache"]);
1374 Config::Bind(MemcacheReadOnly
, ini
, debug
["MemcacheReadOnly"]);
1377 Hdf simpleCounter
= debug
["SimpleCounter"];
1378 Config::Bind(SimpleCounter::SampleStackCount
, ini
,
1379 simpleCounter
["SampleStackCount"], 0);
1380 Config::Bind(SimpleCounter::SampleStackDepth
, ini
,
1381 simpleCounter
["SampleStackDepth"], 5);
1385 Hdf stats
= config
["Stats"];
1386 Config::Bind(EnableStats
, ini
, stats
); // main switch
1388 Config::Bind(EnableAPCStats
, ini
, stats
["APC"], false);
1389 Config::Bind(EnableWebStats
, ini
, stats
["Web"]);
1390 Config::Bind(EnableMemoryStats
, ini
, stats
["Memory"]);
1391 Config::Bind(EnableMemcacheStats
, ini
, stats
["Memcache"]);
1392 Config::Bind(EnableMemcacheKeyStats
, ini
, stats
["MemcacheKey"]);
1393 Config::Bind(EnableSQLStats
, ini
, stats
["SQL"]);
1394 Config::Bind(EnableSQLTableStats
, ini
, stats
["SQLTable"]);
1395 Config::Bind(EnableNetworkIOStatus
, ini
, stats
["NetworkIO"]);
1397 Config::Bind(StatsXSL
, ini
, stats
["XSL"]);
1398 Config::Bind(StatsXSLProxy
, ini
, stats
["XSLProxy"]);
1400 Config::Bind(StatsSlotDuration
, ini
, stats
["SlotDuration"], 10 * 60);
1401 Config::Bind(StatsMaxSlot
, ini
, stats
["MaxSlot"], 12 * 6); // 12 hours
1403 Config::Bind(EnableHotProfiler
, ini
, stats
["EnableHotProfiler"], true);
1404 Config::Bind(ProfilerTraceBuffer
, ini
, stats
["ProfilerTraceBuffer"],
1406 Config::Bind(ProfilerTraceExpansion
, ini
, stats
["ProfilerTraceExpansion"],
1408 Config::Bind(ProfilerMaxTraceBuffer
, ini
, stats
["ProfilerMaxTraceBuffer"],
1412 Config::Bind(ServerVariables
, ini
, config
["ServerVariables"]);
1413 Config::Bind(EnvVariables
, ini
, config
["EnvVariables"]);
1416 Hdf sandbox
= config
["Sandbox"];
1417 Config::Bind(SandboxMode
, ini
, sandbox
["SandboxMode"]);
1418 SandboxPattern
= format_pattern(Config::GetString(ini
, sandbox
["Pattern"]),
1420 Config::Bind(SandboxHome
, ini
, sandbox
["Home"]);
1421 Config::Bind(SandboxFallback
, ini
, sandbox
["Fallback"]);
1422 Config::Bind(SandboxConfFile
, ini
, sandbox
["ConfFile"]);
1423 Config::Bind(SandboxFromCommonRoot
, ini
, sandbox
["FromCommonRoot"]);
1424 Config::Bind(SandboxDirectoriesRoot
, ini
, sandbox
["DirectoriesRoot"]);
1425 Config::Bind(SandboxLogsRoot
, ini
, sandbox
["LogsRoot"]);
1426 Config::Get(ini
, sandbox
["ServerVariables"], SandboxServerVariables
);
1429 Hdf mail
= config
["Mail"];
1430 Config::Bind(SendmailPath
, ini
, mail
["SendmailPath"], "sendmail -t -i");
1431 Config::Bind(MailForceExtraParameters
, ini
, mail
["ForceExtraParameters"]);
1434 Hdf preg
= config
["Preg"];
1435 Config::Bind(PregBacktraceLimit
, ini
, preg
["BacktraceLimit"], 1000000);
1436 Config::Bind(PregRecursionLimit
, ini
, preg
["RecursionLimit"], 100000);
1437 Config::Bind(EnablePregErrorLog
, ini
, preg
["ErrorLog"], true);
1440 Hdf hhprofServer
= config
["HHProfServer"];
1441 Config::Bind(HHProfServerEnabled
, ini
, hhprofServer
["Enabled"], false);
1442 Config::Bind(HHProfServerPort
, ini
, hhprofServer
["Port"], 4327);
1443 Config::Bind(HHProfServerThreads
, ini
, hhprofServer
["Threads"], 2);
1444 Config::Bind(HHProfServerTimeoutSeconds
, ini
,
1445 hhprofServer
["TimeoutSeconds"], 30);
1446 Config::Bind(HHProfServerProfileClientMode
, ini
,
1447 hhprofServer
["ProfileClientMode"], true);
1448 Config::Bind(HHProfServerAllocationProfile
, ini
,
1449 hhprofServer
["AllocationProfile"], false);
1451 // HHProfServer.Filter.*
1452 Hdf hhprofFilter
= hhprofServer
["Filter"];
1453 Config::Bind(HHProfServerFilterMinAllocPerReq
, ini
,
1454 hhprofFilter
["MinAllocPerReq"], 2);
1455 Config::Bind(HHProfServerFilterMinBytesPerReq
, ini
,
1456 hhprofFilter
["MinBytesPerReq"], 128);
1459 Hdf simplexml
= config
["SimpleXML"];
1460 Config::Bind(SimpleXMLEmptyNamespaceMatchesAll
, ini
,
1461 simplexml
["EmptyNamespaceMatchesAll"], false);
1465 Hdf fb303Server
= config
["Fb303Server"];
1466 Config::Bind(EnableFb303Server
, ini
, fb303Server
["Enable"], true);
1467 Config::Bind(Fb303ServerPort
, ini
, fb303Server
["Port"], 0);
1468 Config::Bind(Fb303ServerThreadStackSizeMb
, ini
,
1469 fb303Server
["ThreadStackSizeMb"], 8);
1470 Config::Bind(Fb303ServerWorkerThreads
, ini
, fb303Server
["WorkerThreads"],
1472 Config::Bind(Fb303ServerPoolThreads
, ini
, fb303Server
["PoolThreads"], 1);
1477 Hdf hhprofServer
= config
["Xenon"];
1478 Config::Bind(XenonPeriodSeconds
, ini
, hhprofServer
["Period"], 0.0);
1479 Config::Bind(XenonForceAlwaysOn
, ini
, hhprofServer
["ForceAlwaysOn"], false);
1482 Config::Get(ini
, config
["CustomSettings"], CustomSettings
);
1484 if (RuntimeOption::OptionHooks
!= nullptr) {
1485 for (auto hookFunc
: *RuntimeOption::OptionHooks
) {
1486 hookFunc(ini
, config
);
1490 refineStaticStringTableSize();
1492 // Language and Misc Configuration Options
1493 IniSetting::Bind(IniSetting::CORE
, IniSetting::PHP_INI_ONLY
, "expose_php",
1494 &RuntimeOption::ExposeHPHP
);
1495 IniSetting::Bind(IniSetting::CORE
, IniSetting::PHP_INI_PERDIR
,
1496 "auto_prepend_file", &RuntimeOption::AutoPrependFile
);
1497 IniSetting::Bind(IniSetting::CORE
, IniSetting::PHP_INI_PERDIR
,
1498 "auto_append_file", &RuntimeOption::AutoAppendFile
);
1501 IniSetting::Bind(IniSetting::CORE
, IniSetting::PHP_INI_PERDIR
,
1503 IniSetting::SetAndGet
<int64_t>(
1506 return VirtualHost::GetMaxPostSize();
1509 &RuntimeOption::MaxPostSize
);
1510 IniSetting::Bind(IniSetting::CORE
, IniSetting::PHP_INI_PERDIR
,
1511 "always_populate_raw_post_data",
1512 &RuntimeOption::AlwaysPopulateRawPostData
);
1514 // Paths and Directories
1515 IniSetting::Bind(IniSetting::CORE
, IniSetting::PHP_INI_SYSTEM
,
1516 "doc_root", &RuntimeOption::SourceRoot
);
1519 IniSetting::Bind(IniSetting::CORE
, IniSetting::PHP_INI_ONLY
,
1520 "pid", &RuntimeOption::PidFile
);
1523 IniSetting::Bind(IniSetting::CORE
, IniSetting::PHP_INI_SYSTEM
,
1524 "file_uploads", "true",
1525 &RuntimeOption::EnableFileUploads
);
1526 IniSetting::Bind(IniSetting::CORE
, IniSetting::PHP_INI_SYSTEM
,
1527 "upload_tmp_dir", &RuntimeOption::UploadTmpDir
);
1528 IniSetting::Bind(IniSetting::CORE
, IniSetting::PHP_INI_PERDIR
,
1529 "upload_max_filesize",
1530 IniSetting::SetAndGet
<std::string
>(
1531 [](const std::string
& value
) {
1532 return ini_on_update(
1533 value
, RuntimeOption::UploadMaxFileSize
);
1536 int uploadMaxFilesize
=
1537 VirtualHost::GetUploadMaxFileSize() / (1 << 20);
1538 return std::to_string(uploadMaxFilesize
) + "M";
1541 // Filesystem and Streams Configuration Options
1542 IniSetting::Bind(IniSetting::CORE
, IniSetting::PHP_INI_SYSTEM
,
1544 IniSetting::SetAndGet
<std::string
>(
1545 [](const std::string
& value
) { return false; },
1546 []() { return "1"; }));
1549 IniSetting::Bind(IniSetting::CORE
, IniSetting::PHP_INI_NONE
,
1551 IniSetting::SetAndGet
<std::string
>(
1552 [](const std::string
& value
) { return false; },
1553 []() { return getHphpCompilerId(); }
1555 IniSetting::Bind(IniSetting::CORE
, IniSetting::PHP_INI_NONE
,
1556 "hphp.compiler_version",
1557 IniSetting::SetAndGet
<std::string
>(
1558 [](const std::string
& value
) { return false; },
1559 []() { return getHphpCompilerVersion(); }
1561 IniSetting::Bind(IniSetting::CORE
, IniSetting::PHP_INI_NONE
,
1563 IniSetting::SetAndGet
<std::string
>(
1564 [](const std::string
& value
) { return false; },
1567 &RuntimeOption::BuildId
);
1568 IniSetting::Bind(IniSetting::CORE
, IniSetting::PHP_INI_SYSTEM
,
1570 &RuntimeOption::NoticeFrequency
);
1571 IniSetting::Bind(IniSetting::CORE
, IniSetting::PHP_INI_SYSTEM
,
1572 "warning_frequency",
1573 &RuntimeOption::WarningFrequency
);
1574 IniSetting::Bind(IniSetting::CORE
, IniSetting::PHP_INI_ONLY
,
1576 IniSetting::SetAndGet
<std::string
>(
1577 [](const std::string
&) {
1581 return s_hhvm_build_type
.c_str();
1586 Config::Bind(RuntimeOption::ExtensionDir
, ini
, "extension_dir",
1587 RuntimeOption::ExtensionDir
);
1588 Config::Bind(RuntimeOption::DynamicExtensionPath
, ini
,
1589 config
["DynamicExtensionPath"],
1590 RuntimeOption::DynamicExtensionPath
);
1591 // there is no way to bind array ini/hdf settings.
1592 Config::Get(ini
, config
["extensions"], RuntimeOption::Extensions
);
1593 Config::Get(ini
, config
["DynamicExtensions"],
1594 RuntimeOption::DynamicExtensions
);
1597 Extension::LoadModules(ini
, config
);
1598 extern void initialize_apc();
1602 ///////////////////////////////////////////////////////////////////////////////