passenger 5.3.4 → 5.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +13 -0
  3. data/CODE_OF_CONDUCT.md +1 -1
  4. data/build/cxx_tests.rb +12 -1
  5. data/build/misc.rb +2 -1
  6. data/build/packaging.rb +2 -0
  7. data/build/support/cplusplus.rb +2 -2
  8. data/build/support/cxx_dependency_map.rb +653 -383
  9. data/dev/configkit-schemas/index.json +105 -3
  10. data/dev/show-latest-crashlog-dir +27 -0
  11. data/resources/templates/standalone/http.erb +2 -0
  12. data/src/agent/Core/AdminPanelConnector.h +2 -2
  13. data/src/agent/Core/ApplicationPool/Context.h +5 -1
  14. data/src/agent/Core/ApplicationPool/Group.h +2 -0
  15. data/src/agent/Core/ApplicationPool/Group/LifetimeAndBasics.cpp +5 -0
  16. data/src/agent/Core/ApplicationPool/Group/Miscellaneous.cpp +2 -1
  17. data/src/agent/Core/ApplicationPool/Group/ProcessListManagement.cpp +1 -1
  18. data/src/agent/Core/ApplicationPool/Group/StateInspection.cpp +12 -19
  19. data/src/agent/Core/ApplicationPool/Options.h +35 -31
  20. data/src/agent/Core/ApplicationPool/Pool/GroupUtils.cpp +2 -1
  21. data/src/agent/Core/ApplicationPool/Socket.h +1 -1
  22. data/src/agent/Core/Config.h +38 -7
  23. data/src/agent/Core/ConfigChange.cpp +13 -1
  24. data/src/agent/Core/Controller.h +3 -1
  25. data/src/agent/Core/Controller/Config.h +14 -11
  26. data/src/agent/Core/Controller/InitRequest.cpp +6 -5
  27. data/src/agent/Core/Controller/InitializationAndShutdown.cpp +3 -0
  28. data/src/agent/Core/CoreMain.cpp +149 -34
  29. data/src/agent/Core/OptionParser.h +12 -1
  30. data/src/agent/Core/SpawningKit/Config.h +1 -1
  31. data/src/agent/Core/SpawningKit/Context.h +7 -1
  32. data/src/agent/Core/SpawningKit/Exceptions.h +15 -12
  33. data/src/agent/Core/SpawningKit/README.md +34 -17
  34. data/src/agent/Core/SpawningKit/Spawner.h +5 -3
  35. data/src/agent/Core/SpawningKit/UserSwitchingRules.h +5 -2
  36. data/src/agent/Core/TelemetryCollector.h +674 -0
  37. data/src/agent/Shared/Fundamentals/AbortHandler.cpp +309 -83
  38. data/src/agent/Shared/Fundamentals/AbortHandler.h +18 -3
  39. data/src/agent/Watchdog/Config.h +21 -4
  40. data/src/agent/Watchdog/WatchdogMain.cpp +4 -1
  41. data/src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp +10 -0
  42. data/src/apache2_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.cpp +5 -0
  43. data/src/apache2_module/ConfigGeneral/AutoGeneratedSetterFuncs.cpp +30 -0
  44. data/src/apache2_module/DirectoryMapper.h +24 -36
  45. data/src/apache2_module/Hooks.cpp +13 -5
  46. data/src/apache2_module/ServerConfig/AutoGeneratedManifestGeneration.cpp +20 -0
  47. data/src/apache2_module/ServerConfig/AutoGeneratedStruct.h +24 -0
  48. data/src/cxx_supportlib/AppTypeDetector/CBindings.cpp +136 -0
  49. data/src/cxx_supportlib/AppTypeDetector/CBindings.h +73 -0
  50. data/src/cxx_supportlib/{AppTypes.h → AppTypeDetector/Detector.h} +59 -132
  51. data/src/cxx_supportlib/ConfigKit/README.md +90 -2
  52. data/src/cxx_supportlib/ConfigKit/Schema.h +58 -13
  53. data/src/cxx_supportlib/ConfigKit/Store.h +128 -4
  54. data/src/cxx_supportlib/Constants.h +1 -1
  55. data/src/cxx_supportlib/ProcessManagement/Ruby.cpp +3 -3
  56. data/src/cxx_supportlib/ProcessManagement/Ruby.h +7 -2
  57. data/src/cxx_supportlib/ProcessManagement/Spawn.cpp +14 -7
  58. data/src/cxx_supportlib/ProcessManagement/Spawn.h +21 -2
  59. data/src/cxx_supportlib/ResourceLocator.h +1 -1
  60. data/src/cxx_supportlib/ServerKit/ClientRef.h +17 -7
  61. data/src/cxx_supportlib/ServerKit/HttpRequestRef.h +17 -7
  62. data/src/cxx_supportlib/Utils/IOUtils.cpp +2 -1
  63. data/src/cxx_supportlib/Utils/ProcessMetricsCollector.h +9 -6
  64. data/src/cxx_supportlib/WrapperRegistry/CBindings.cpp +85 -0
  65. data/src/cxx_supportlib/WrapperRegistry/CBindings.h +56 -0
  66. data/src/cxx_supportlib/WrapperRegistry/Entry.h +112 -0
  67. data/src/cxx_supportlib/WrapperRegistry/README.md +37 -0
  68. data/src/cxx_supportlib/WrapperRegistry/Registry.h +309 -0
  69. data/src/helper-scripts/download_binaries/extconf.rb +6 -2
  70. data/src/nginx_module/ConfigGeneral/AutoGeneratedDefinitions.c +16 -0
  71. data/src/nginx_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.c +6 -0
  72. data/src/nginx_module/ConfigGeneral/AutoGeneratedSetterFuncs.c +24 -0
  73. data/src/nginx_module/ContentHandler.c +34 -13
  74. data/src/nginx_module/ContentHandler.h +3 -3
  75. data/src/nginx_module/MainConfig/AutoGeneratedCreateFunction.c +11 -0
  76. data/src/nginx_module/MainConfig/AutoGeneratedManifestGeneration.c +23 -0
  77. data/src/nginx_module/MainConfig/AutoGeneratedStruct.h +8 -0
  78. data/src/nginx_module/config +2 -1
  79. data/src/nginx_module/ngx_http_passenger_module.c +9 -3
  80. data/src/nginx_module/ngx_http_passenger_module.h +4 -2
  81. data/src/ruby_supportlib/phusion_passenger.rb +2 -1
  82. data/src/ruby_supportlib/phusion_passenger/apache2/config_options.rb +13 -0
  83. data/src/ruby_supportlib/phusion_passenger/common_library.rb +8 -5
  84. data/src/ruby_supportlib/phusion_passenger/config/download_agent_command.rb +6 -2
  85. data/src/ruby_supportlib/phusion_passenger/config/download_nginx_engine_command.rb +6 -2
  86. data/src/ruby_supportlib/phusion_passenger/native_support.rb +7 -3
  87. data/src/ruby_supportlib/phusion_passenger/nginx/config_options.rb +15 -0
  88. data/src/ruby_supportlib/phusion_passenger/standalone/config_options_list.rb +11 -1
  89. data/src/ruby_supportlib/phusion_passenger/standalone/start_command/builtin_engine.rb +3 -1
  90. metadata +12 -4
  91. data/src/cxx_supportlib/AppTypes.cpp +0 -109
@@ -0,0 +1,136 @@
1
+ /*
2
+ * Phusion Passenger - https://www.phusionpassenger.com/
3
+ * Copyright (c) 2018 Phusion Holding B.V.
4
+ *
5
+ * "Passenger", "Phusion Passenger" and "Union Station" are registered
6
+ * trademarks of Phusion Holding B.V.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in
16
+ * all copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ * THE SOFTWARE.
25
+ */
26
+
27
+ #include <cstddef>
28
+ #include <new>
29
+ #include <exception>
30
+
31
+ #include <StaticString.h>
32
+ #include <AppTypeDetector/CBindings.h>
33
+ #include <AppTypeDetector/Detector.h>
34
+
35
+ using namespace Passenger;
36
+ using namespace Passenger::WrapperRegistry;
37
+ using namespace Passenger::AppTypeDetector;
38
+
39
+
40
+ size_t
41
+ psg_app_type_detector_result_get_object_size() {
42
+ return sizeof(Detector::Result);
43
+ }
44
+
45
+ PsgAppTypeDetectorResult *
46
+ psg_app_type_detector_result_init(void *memory) {
47
+ Detector::Result *cxxResult = new (memory) Detector::Result();
48
+ return static_cast<PsgAppTypeDetectorResult *>(cxxResult);
49
+ }
50
+
51
+ void
52
+ psg_app_type_detector_result_deinit(PsgAppTypeDetectorResult *result) {
53
+ Detector::Result *cxxResult = static_cast<Detector::Result *>(result);
54
+ cxxResult->~Result();
55
+ }
56
+
57
+ int
58
+ psg_app_type_detector_result_is_null(const PsgAppTypeDetectorResult *result) {
59
+ const Detector::Result *cxxResult = static_cast<const Detector::Result *>(result);
60
+ return (int) cxxResult->isNull();
61
+ }
62
+
63
+ const PsgWrapperRegistryEntry *
64
+ psg_app_type_detector_result_get_wrapper_registry_entry(const PsgAppTypeDetectorResult *result) {
65
+ const Detector::Result *cxxResult = static_cast<const Detector::Result *>(result);
66
+ return static_cast<const PsgWrapperRegistryEntry *>(cxxResult->wrapperRegistryEntry);
67
+ }
68
+
69
+ void
70
+ psg_app_type_detector_result_set_wrapper_registry_entry(PsgAppTypeDetectorResult *result,
71
+ const PsgWrapperRegistryEntry *entry)
72
+ {
73
+ Detector::Result *cxxResult = static_cast<Detector::Result *>(result);
74
+ cxxResult->wrapperRegistryEntry = static_cast<const WrapperRegistry::Entry *>(entry);
75
+ }
76
+
77
+
78
+ PsgAppTypeDetector *
79
+ psg_app_type_detector_new(const PsgWrapperRegistry *registry,
80
+ unsigned int throttleRate)
81
+ {
82
+ const Registry *cxxRegistry = static_cast<const Registry *>(registry);
83
+ try {
84
+ Detector *detector = new Detector(*cxxRegistry, NULL, NULL, throttleRate);
85
+ return static_cast<PsgAppTypeDetector *>(detector);
86
+ } catch (const std::bad_alloc &) {
87
+ return NULL;
88
+ }
89
+ }
90
+
91
+ void
92
+ psg_app_type_detector_free(PsgAppTypeDetector *detector) {
93
+ Detector *cxxDetector = static_cast<Detector *>(detector);
94
+ delete cxxDetector;
95
+ }
96
+
97
+ void
98
+ psg_app_type_detector_set_throttle_rate(PsgAppTypeDetector *detector,
99
+ unsigned int throttleRate)
100
+ {
101
+ Detector *cxxDetector = static_cast<Detector *>(detector);
102
+ cxxDetector->setThrottleRate(throttleRate);
103
+ }
104
+
105
+ void
106
+ psg_app_type_detector_check_document_root(
107
+ PsgAppTypeDetector *detector, PsgAppTypeDetectorResult *result,
108
+ const char *documentRoot, unsigned int len, int resolveFirstSymlink,
109
+ PP_Error *error)
110
+ {
111
+ Detector *cxxDetector = static_cast<Detector *>(detector);
112
+ Detector::Result *cxxResult = static_cast<Detector::Result *>(result);
113
+ try {
114
+ *cxxResult = cxxDetector->checkDocumentRoot(
115
+ StaticString(documentRoot, len), resolveFirstSymlink);
116
+ } catch (const std::exception &e) {
117
+ pp_error_set(e, error);
118
+ *cxxResult = Detector::Result();
119
+ }
120
+ }
121
+
122
+ void
123
+ psg_app_type_detector_check_app_root(
124
+ PsgAppTypeDetector *detector, PsgAppTypeDetectorResult *result,
125
+ const char *appRoot, unsigned int len, PP_Error *error)
126
+ {
127
+ Detector *cxxDetector = static_cast<Detector *>(detector);
128
+ Detector::Result *cxxResult = static_cast<Detector::Result *>(result);
129
+ try {
130
+ *cxxResult = cxxDetector->checkAppRoot(
131
+ StaticString(appRoot, len));
132
+ } catch (const std::exception &e) {
133
+ pp_error_set(e, error);
134
+ *cxxResult = Detector::Result();
135
+ }
136
+ }
@@ -0,0 +1,73 @@
1
+ /*
2
+ * Phusion Passenger - https://www.phusionpassenger.com/
3
+ * Copyright (c) 2018 Phusion Holding B.V.
4
+ *
5
+ * "Passenger", "Phusion Passenger" and "Union Station" are registered
6
+ * trademarks of Phusion Holding B.V.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in
16
+ * all copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ * THE SOFTWARE.
25
+ */
26
+ #ifndef _PASSENGER_APP_TYPE_DETECTOR_CBINDINGS_H_
27
+ #define _PASSENGER_APP_TYPE_DETECTOR_CBINDINGS_H_
28
+
29
+ #include <stddef.h>
30
+ #include "../WrapperRegistry/CBindings.h"
31
+ #include "../Exceptions.h"
32
+
33
+ #ifdef __cplusplus
34
+ extern "C" {
35
+ #endif
36
+
37
+
38
+ typedef void PsgAppTypeDetectorResult;
39
+
40
+ size_t psg_app_type_detector_result_get_object_size();
41
+ PsgAppTypeDetectorResult *psg_app_type_detector_result_init(void *memory);
42
+ void psg_app_type_detector_result_deinit(PsgAppTypeDetectorResult *result);
43
+
44
+ int psg_app_type_detector_result_is_null(const PsgAppTypeDetectorResult *result);
45
+ const PsgWrapperRegistryEntry *psg_app_type_detector_result_get_wrapper_registry_entry(
46
+ const PsgAppTypeDetectorResult *result);
47
+ void psg_app_type_detector_result_set_wrapper_registry_entry(PsgAppTypeDetectorResult *result,
48
+ const PsgWrapperRegistryEntry *entry);
49
+
50
+
51
+ typedef void PsgAppTypeDetector;
52
+
53
+ PsgAppTypeDetector *psg_app_type_detector_new(const PsgWrapperRegistry *registry,
54
+ unsigned int throttleRate);
55
+ void psg_app_type_detector_free(PsgAppTypeDetector *detector);
56
+ void psg_app_type_detector_set_throttle_rate(PsgAppTypeDetector *detector,
57
+ unsigned int throttleRate);
58
+ void psg_app_type_detector_check_document_root(
59
+ PsgAppTypeDetector *detector,
60
+ PsgAppTypeDetectorResult *result,
61
+ const char *documentRoot, unsigned int len, int resolveFirstSymlink,
62
+ PP_Error *error);
63
+ void psg_app_type_detector_check_app_root(
64
+ PsgAppTypeDetector *detector,
65
+ PsgAppTypeDetectorResult *result,
66
+ const char *appRoot, unsigned int len, PP_Error *error);
67
+
68
+
69
+ #ifdef __cplusplus
70
+ } // extern "C"
71
+ #endif
72
+
73
+ #endif /* _PASSENGER_APP_TYPE_DETECTOR_CBINDINGS_H_ */
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * Phusion Passenger - https://www.phusionpassenger.com/
3
- * Copyright (c) 2013-2017 Phusion Holding B.V.
3
+ * Copyright (c) 2018 Phusion Holding B.V.
4
4
  *
5
5
  * "Passenger", "Phusion Passenger" and "Union Station" are registered
6
6
  * trademarks of Phusion Holding B.V.
@@ -23,117 +23,89 @@
23
23
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
24
  * THE SOFTWARE.
25
25
  */
26
- #ifndef _PASSENGER_APP_TYPES_H_
27
- #define _PASSENGER_APP_TYPES_H_
28
-
29
- /**
30
- * Application type registry
31
- *
32
- * All supported application types (e.g. Rack, classic Rails, WSGI, etc)
33
- * are registered here. The AppTypeDetector is responsible for checking
34
- * what kind of application lives under the given directory.
35
- */
36
-
37
- #include "Exceptions.h"
38
-
39
-
40
- #ifdef __cplusplus
41
- extern "C" {
42
- #endif /* __cplusplus */
43
-
44
- typedef enum {
45
- PAT_RACK,
46
- PAT_WSGI,
47
- PAT_NODE,
48
- PAT_METEOR,
49
- PAT_NONE,
50
- PAT_ERROR
51
- } PassengerAppType;
52
-
53
- typedef void PP_AppTypeDetector;
54
-
55
- PP_AppTypeDetector *pp_app_type_detector_new(unsigned int throttleRate);
56
- void pp_app_type_detector_free(PP_AppTypeDetector *detector);
57
- void pp_app_type_detector_set_throttle_rate(PP_AppTypeDetector *detector,
58
- unsigned int throttleRate);
59
- PassengerAppType pp_app_type_detector_check_document_root(PP_AppTypeDetector *detector,
60
- const char *documentRoot, unsigned int len, int resolveFirstSymlink,
61
- PP_Error *error);
62
- PassengerAppType pp_app_type_detector_check_app_root(PP_AppTypeDetector *detector,
63
- const char *appRoot, unsigned int len, PP_Error *error);
64
-
65
- const char *pp_get_app_type_name(PassengerAppType type);
66
- PassengerAppType pp_get_app_type2(const char *name, unsigned int len);
67
-
68
- #ifdef __cplusplus
69
- }
70
- #endif /* __cplusplus */
26
+ #ifndef _PASSENGER_APP_TYPE_DECTECTOR_H_
27
+ #define _PASSENGER_APP_TYPE_DECTECTOR_H_
71
28
 
29
+ #include <limits.h>
72
30
 
73
- #ifdef __cplusplus
31
+ #include <boost/thread.hpp>
32
+ #include <boost/foreach.hpp>
74
33
  #include <oxt/macros.hpp>
75
34
  #include <oxt/backtrace.hpp>
76
- #include <boost/thread.hpp>
77
- #include <cstdlib>
78
- #include <limits.h>
35
+
36
+ #include <cassert>
37
+ #include <cstddef>
79
38
  #include <string>
80
- #include <LoggingKit/LoggingKit.h>
81
- #include <StaticString.h>
39
+
40
+ #include <Exceptions.h>
41
+ #include <WrapperRegistry/Registry.h>
82
42
  #include <FileTools/PathManip.h>
83
43
  #include <FileTools/FileManip.h>
84
44
  #include <Utils.h>
85
- #include <Utils/StrIntUtils.h>
86
45
  #include <Utils/CachedFileStat.hpp>
46
+ #include <Utils/StrIntUtils.h>
87
47
 
88
48
  namespace Passenger {
49
+ namespace AppTypeDetector {
89
50
 
90
51
  using namespace std;
91
52
 
92
53
 
93
- struct AppTypeDefinition {
94
- const PassengerAppType type;
95
- const char * const name;
96
- const char * const startupFile;
97
- const char * const processTitle;
98
- };
54
+ class Detector {
55
+ public:
56
+ struct Result {
57
+ const WrapperRegistry::Entry *wrapperRegistryEntry;
99
58
 
100
- extern const AppTypeDefinition appTypeDefinitions[];
59
+ Result()
60
+ : wrapperRegistryEntry(NULL)
61
+ { }
101
62
 
63
+ bool isNull() const {
64
+ return wrapperRegistryEntry == NULL;
65
+ }
66
+ };
102
67
 
103
- class AppTypeDetector {
104
68
  private:
69
+ const WrapperRegistry::Registry &registry;
105
70
  CachedFileStat *cstat;
106
71
  boost::mutex *cstatMutex;
107
72
  unsigned int throttleRate;
108
73
  bool ownsCstat;
109
74
 
110
- bool check(char *buf, const char *end, const StaticString &appRoot, const char *name) {
75
+ bool check(char *buf, const char *end, const StaticString &appRoot,
76
+ const StaticString &name)
77
+ {
111
78
  char *pos = buf;
112
79
  pos = appendData(pos, end, appRoot);
113
- pos = appendData(pos, end, "/");
80
+ pos = appendData(pos, end, "/", 1);
114
81
  pos = appendData(pos, end, name);
115
82
  pos = appendData(pos, end, "\0", 1);
116
83
  if (OXT_UNLIKELY(pos == end)) {
117
84
  TRACE_POINT();
118
85
  throw RuntimeException("Not enough buffer space");
119
86
  }
120
- return getFileType(StaticString(buf, pos - buf - 1), cstat, cstatMutex, throttleRate) != FT_NONEXISTANT;
87
+ return getFileType(StaticString(buf, pos - buf - 1),
88
+ cstat, cstatMutex, throttleRate) != FT_NONEXISTANT;
121
89
  }
122
90
 
123
91
  public:
124
- AppTypeDetector(CachedFileStat *_cstat = NULL, boost::mutex *_cstatMutex = NULL, unsigned int _throttleRate = 1)
125
- : cstat(_cstat),
92
+ Detector(const WrapperRegistry::Registry &_registry,
93
+ CachedFileStat *_cstat = NULL, boost::mutex *_cstatMutex = NULL,
94
+ unsigned int _throttleRate = 1)
95
+ : registry(_registry),
96
+ cstat(_cstat),
126
97
  cstatMutex(_cstatMutex),
127
98
  throttleRate(_throttleRate),
128
99
  ownsCstat(false)
129
100
  {
101
+ assert(_registry.isFinalized());
130
102
  if (_cstat == NULL) {
131
103
  cstat = new CachedFileStat();
132
104
  ownsCstat = true;
133
105
  }
134
106
  }
135
107
 
136
- ~AppTypeDetector() {
108
+ ~Detector() {
137
109
  if (ownsCstat) {
138
110
  delete cstat;
139
111
  }
@@ -146,7 +118,7 @@ public:
146
118
  /**
147
119
  * Given a web server document root (that is, some subdirectory under the
148
120
  * application root, e.g. "/webapps/foobar/public"), returns the type of
149
- * application that lives there. Returns PAT_NONE if it wasn't able to detect
121
+ * application that lives there. Returns a null result if it wasn't able to detect
150
122
  * a supported application type.
151
123
  *
152
124
  * If `resolveFirstSymlink` is given, and `documentRoot` is a symlink, then
@@ -161,7 +133,7 @@ public:
161
133
  * @throws TimeRetrievalException
162
134
  * @throws boost::thread_interrupted
163
135
  */
164
- PassengerAppType checkDocumentRoot(const StaticString &documentRoot,
136
+ const Result checkDocumentRoot(const StaticString &documentRoot,
165
137
  bool resolveFirstSymlink = false,
166
138
  string *appRoot = NULL)
167
139
  {
@@ -193,83 +165,38 @@ public:
193
165
 
194
166
  /**
195
167
  * Returns the type of application that lives under the application
196
- * directory `appRoot`. Returns PAT_NONE if it wasn't able to detect
168
+ * directory `appRoot`. Returns a null result if it wasn't able to detect
197
169
  * a supported application type.
198
170
  *
199
171
  * @throws FileSystemException Unable to check because of a filesystem error.
200
172
  * @throws TimeRetrievalException
201
173
  * @throws boost::thread_interrupted
202
174
  */
203
- PassengerAppType checkAppRoot(const StaticString &appRoot) {
175
+ const Result checkAppRoot(const StaticString &appRoot) {
204
176
  char buf[PATH_MAX + 32];
205
177
  const char *end = buf + sizeof(buf) - 1;
206
- const AppTypeDefinition *definition = &appTypeDefinitions[0];
207
178
 
208
- while (definition->type != PAT_NONE) {
209
- if (check(buf, end, appRoot, definition->startupFile)) {
210
- return definition->type;
179
+ WrapperRegistry::Registry::ConstIterator it(registry.getIterator());
180
+ while (*it != NULL) {
181
+ const WrapperRegistry::Entry &entry = it.getValue();
182
+ foreach (const StaticString &defaultStartupFile,
183
+ entry.defaultStartupFiles)
184
+ {
185
+ if (check(buf, end, appRoot, defaultStartupFile)) {
186
+ Result result;
187
+ result.wrapperRegistryEntry = &entry;
188
+ return result;
189
+ }
211
190
  }
212
- definition++;
213
- }
214
- return PAT_NONE;
215
- }
216
- };
217
-
218
-
219
- inline const char *
220
- getAppTypeName(PassengerAppType type) {
221
- const AppTypeDefinition *definition = &appTypeDefinitions[0];
222
-
223
- while (definition->type != PAT_NONE) {
224
- if (definition->type == type) {
225
- return definition->name;
226
- }
227
- definition++;
228
- }
229
- return NULL;
230
- }
231
-
232
- inline PassengerAppType
233
- getAppType(const StaticString &name) {
234
- const AppTypeDefinition *definition = &appTypeDefinitions[0];
235
-
236
- while (definition->type != PAT_NONE) {
237
- if (name == definition->name) {
238
- return definition->type;
239
- }
240
- definition++;
241
- }
242
- return PAT_NONE;
243
- }
244
-
245
- inline const char *
246
- getAppTypeStartupFile(PassengerAppType type) {
247
- const AppTypeDefinition *definition = &appTypeDefinitions[0];
248
-
249
- while (definition->type != PAT_NONE) {
250
- if (definition->type == type) {
251
- return definition->startupFile;
191
+ it.next();
252
192
  }
253
- definition++;
254
- }
255
- return NULL;
256
- }
257
-
258
- inline const char *
259
- getAppTypeProcessTitle(PassengerAppType type) {
260
- const AppTypeDefinition *definition = &appTypeDefinitions[0];
261
193
 
262
- while (definition->type != PAT_NONE) {
263
- if (definition->type == type) {
264
- return definition->processTitle;
265
- }
266
- definition++;
194
+ return Result();
267
195
  }
268
- return NULL;
269
- }
196
+ };
270
197
 
271
198
 
199
+ } // namespace AppTypeDetector
272
200
  } // namespace Passenger
273
- #endif /* __cplusplus */
274
201
 
275
- #endif /* _PASSENGER_APP_TYPES_H_ */
202
+ #endif /* _PASSENGER_APP_TYPE_DECTECTOR_H_ */