passenger 5.1.10 → 5.1.11
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of passenger might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG +18 -0
- data/Rakefile +20 -17
- data/bin/passenger-install-apache2-module +14 -11
- data/build/agent.rb +45 -18
- data/build/apache2.rb +32 -16
- data/build/basics.rb +29 -40
- data/build/common_library.rb +70 -54
- data/build/cxx_tests.rb +34 -43
- data/build/integration_tests.rb +10 -10
- data/build/misc.rb +6 -6
- data/build/node_tests.rb +1 -2
- data/build/oxt_tests.rb +7 -5
- data/build/packaging.rb +11 -441
- data/build/ruby_extension.rb +1 -1
- data/build/ruby_tests.rb +1 -2
- data/build/support/cplusplus.rb +6 -5
- data/build/support/cxx_dependency_map.rb +357 -833
- data/build/support/general.rb +23 -1
- data/build/test_basics.rb +3 -28
- data/dev/ci/tests/rpm/Jenkinsfile +68 -0
- data/dev/ci/tests/rpm/run +63 -0
- data/dev/ci/tests/source-packaging/run +1 -1
- data/dev/ci/tests/source-packaging/setup +1 -1
- data/doc/{Packaging.txt.md → Packaging.md} +0 -0
- data/resources/templates/apache2/deployment_example.txt.erb +2 -2
- data/resources/templates/apache2/multiple_apache_installations_detected.txt.erb +2 -2
- data/resources/templates/nginx/deployment_example.txt.erb +1 -1
- data/resources/templates/standalone/mass_deployment_default_server.erb +2 -2
- data/resources/templates/standalone/server.erb +2 -2
- data/src/agent/AgentMain.cpp +0 -4
- data/src/agent/Core/CoreMain.cpp +88 -5
- data/src/agent/Core/SpawningKit/Spawner.h +2 -1
- data/src/agent/Shared/Fundamentals/AbortHandler.cpp +1109 -0
- data/src/agent/Shared/Fundamentals/AbortHandler.h +63 -0
- data/src/agent/Shared/Fundamentals/Implementation.cpp +7 -0
- data/src/agent/Shared/Fundamentals/Initialization.cpp +614 -0
- data/src/agent/Shared/{Base.h → Fundamentals/Initialization.h} +23 -14
- data/src/agent/Shared/Fundamentals/Utils.cpp +127 -0
- data/src/agent/Shared/Fundamentals/Utils.h +46 -0
- data/src/agent/TempDirToucher/TempDirToucherMain.cpp +1 -1
- data/src/agent/Watchdog/CoreWatcher.cpp +3 -1
- data/src/agent/Watchdog/InstanceDirToucher.cpp +90 -53
- data/src/agent/Watchdog/WatchdogMain.cpp +13 -29
- data/src/apache2_module/Hooks.cpp +4 -1
- data/src/cxx_supportlib/ConfigKit/Store.h +32 -5
- data/src/cxx_supportlib/Constants.h +1 -2
- data/src/cxx_supportlib/Crypto.cpp +2 -1
- data/src/cxx_supportlib/Hooks.h +16 -37
- data/src/cxx_supportlib/LoggingKit/Context.h +22 -0
- data/src/cxx_supportlib/LoggingKit/Forward.h +1 -0
- data/src/cxx_supportlib/LoggingKit/Implementation.cpp +106 -22
- data/src/cxx_supportlib/ProcessManagement/Ruby.cpp +106 -0
- data/src/{agent/UstRouter/FileSink.h → cxx_supportlib/ProcessManagement/Ruby.h} +23 -47
- data/src/cxx_supportlib/ProcessManagement/Spawn.cpp +199 -0
- data/src/cxx_supportlib/ProcessManagement/Spawn.h +150 -0
- data/src/cxx_supportlib/ProcessManagement/Utils.cpp +459 -0
- data/src/cxx_supportlib/ProcessManagement/Utils.h +107 -0
- data/src/cxx_supportlib/Utils.cpp +41 -561
- data/src/cxx_supportlib/Utils.h +0 -68
- data/src/cxx_supportlib/Utils/AsyncSignalSafeUtils.h +187 -0
- data/src/cxx_supportlib/Utils/ProcessMetricsCollector.h +14 -2
- data/src/cxx_supportlib/WatchdogLauncher.h +2 -12
- data/src/cxx_supportlib/oxt/dynamic_thread_group.hpp +2 -2
- data/src/cxx_supportlib/vendor-modified/jsoncpp/json-forwards.h +4 -0
- data/src/cxx_supportlib/vendor-modified/jsoncpp/json.h +16 -1
- data/src/cxx_supportlib/vendor-modified/jsoncpp/jsoncpp.cpp +12 -9
- data/src/cxx_supportlib/vendor-modified/libev/ev++.h +4 -4
- data/src/cxx_supportlib/vendor-modified/libev/ev.h +3 -3
- data/src/nginx_module/CacheLocationConfig.c +0 -75
- data/src/nginx_module/CacheLocationConfig.c.cxxcodebuilder +1 -0
- data/src/nginx_module/Configuration.c +0 -1
- data/src/nginx_module/Configuration.h +0 -1
- data/src/nginx_module/ConfigurationCommands.c +1 -1
- data/src/nginx_module/ContentHandler.c +0 -1
- data/src/nginx_module/ContentHandler.h +0 -1
- data/src/nginx_module/CreateLocationConfig.c +0 -5
- data/src/nginx_module/CreateLocationConfig.c.cxxcodebuilder +1 -0
- data/src/nginx_module/LocationConfig.h +0 -4
- data/src/nginx_module/LocationConfig.h.cxxcodebuilder +2 -1
- data/src/nginx_module/MergeLocationConfig.c +0 -12
- data/src/nginx_module/MergeLocationConfig.c.cxxcodebuilder +1 -0
- data/src/nginx_module/ngx_http_passenger_module.h +0 -1
- data/src/ruby_supportlib/phusion_passenger.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/common_library.rb +20 -11
- data/src/ruby_supportlib/phusion_passenger/config/api_call_command.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/config/reopen_logs_command.rb +0 -1
- data/src/ruby_supportlib/phusion_passenger/config/validate_install_command.rb +10 -3
- data/src/ruby_supportlib/phusion_passenger/console_text_template.rb +3 -1
- data/src/ruby_supportlib/phusion_passenger/constants.rb +0 -1
- data/src/ruby_supportlib/phusion_passenger/debug_logging.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/loader_shared_helpers.rb +32 -6
- data/src/ruby_supportlib/phusion_passenger/nginx/config_options.rb +0 -1
- data/src/ruby_supportlib/phusion_passenger/packaging.rb +2 -4
- data/src/ruby_supportlib/phusion_passenger/platform_info/apache.rb +101 -20
- data/src/ruby_supportlib/phusion_passenger/platform_info/apache_detector.rb +21 -9
- data/src/ruby_supportlib/phusion_passenger/platform_info/compiler.rb +34 -31
- data/src/ruby_supportlib/phusion_passenger/platform_info/cxx_portability.rb +3 -1
- data/src/ruby_supportlib/phusion_passenger/platform_info/depcheck_specs/apache2.rb +2 -14
- data/src/ruby_supportlib/phusion_passenger/platform_info/operating_system.rb +40 -3
- data/src/ruby_supportlib/phusion_passenger/standalone/app_finder.rb +15 -14
- data/src/ruby_supportlib/phusion_passenger/standalone/config_options_list.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/standalone/config_utils.rb +1 -1
- data/src/ruby_supportlib/phusion_passenger/standalone/start_command.rb +8 -3
- data/src/ruby_supportlib/phusion_passenger/standalone/start_command/nginx_engine.rb +19 -18
- data/src/ruby_supportlib/phusion_passenger/standalone/stop_command.rb +6 -1
- data/src/ruby_supportlib/phusion_passenger/vendor/daemon_controller.rb +17 -1
- metadata +19 -97
- data/build/documentation.rb +0 -70
- data/doc/CloudLicensingConfiguration.html +0 -172
- data/doc/CloudLicensingConfiguration.txt.md +0 -3
- data/doc/Packaging.html +0 -488
- data/doc/Security of user switching support.idmap.txt +0 -34
- data/doc/Security of user switching support.txt +0 -197
- data/doc/ServerOptimizationGuide.html +0 -172
- data/doc/ServerOptimizationGuide.txt.md +0 -3
- data/doc/images/by_sa.png +0 -0
- data/doc/images/cloud_licensing_batch_job.png +0 -0
- data/doc/images/code_walkthrough.jpg +0 -0
- data/doc/images/direct_spawning.png +0 -0
- data/doc/images/direct_spawning.svg +0 -251
- data/doc/images/glyphicons-halflings-white.png +0 -0
- data/doc/images/glyphicons-halflings.png +0 -0
- data/doc/images/icons/README +0 -5
- data/doc/images/icons/callouts/1.png +0 -0
- data/doc/images/icons/callouts/10.png +0 -0
- data/doc/images/icons/callouts/11.png +0 -0
- data/doc/images/icons/callouts/12.png +0 -0
- data/doc/images/icons/callouts/13.png +0 -0
- data/doc/images/icons/callouts/14.png +0 -0
- data/doc/images/icons/callouts/15.png +0 -0
- data/doc/images/icons/callouts/2.png +0 -0
- data/doc/images/icons/callouts/3.png +0 -0
- data/doc/images/icons/callouts/4.png +0 -0
- data/doc/images/icons/callouts/5.png +0 -0
- data/doc/images/icons/callouts/6.png +0 -0
- data/doc/images/icons/callouts/7.png +0 -0
- data/doc/images/icons/callouts/8.png +0 -0
- data/doc/images/icons/callouts/9.png +0 -0
- data/doc/images/icons/caution.png +0 -0
- data/doc/images/icons/example.png +0 -0
- data/doc/images/icons/home.png +0 -0
- data/doc/images/icons/important.png +0 -0
- data/doc/images/icons/next.png +0 -0
- data/doc/images/icons/note.png +0 -0
- data/doc/images/icons/prev.png +0 -0
- data/doc/images/icons/tip.png +0 -0
- data/doc/images/icons/up.png +0 -0
- data/doc/images/icons/warning.png +0 -0
- data/doc/images/many_web_framework_protocols.png +0 -0
- data/doc/images/passenger_architecture.png +0 -0
- data/doc/images/passenger_architecture.svg +0 -385
- data/doc/images/passenger_architecture_overview.png +0 -0
- data/doc/images/passenger_core_architecture.png +0 -0
- data/doc/images/passenger_nodejs_architecture.svg +0 -558
- data/doc/images/phusion_banner.png +0 -0
- data/doc/images/rack.png +0 -0
- data/doc/images/smart_spawning.png +0 -0
- data/doc/images/smart_spawning.svg +0 -323
- data/doc/images/spawn_server_architecture.png +0 -0
- data/doc/images/spawn_server_architecture.svg +0 -655
- data/doc/images/spawning_preparation_work.png +0 -0
- data/doc/images/startup_sequence.png +0 -0
- data/doc/images/typical_isolated_web_application.png +0 -0
- data/doc/images/typical_isolated_web_application.svg +0 -213
- data/doc/users_guide_snippets/alternative_for_flying_passenger.txt +0 -1
- data/doc/users_guide_snippets/analysis_and_system_maintenance.txt +0 -61
- data/doc/users_guide_snippets/appendix_a_about.txt +0 -13
- data/doc/users_guide_snippets/appendix_b_terminology.txt +0 -71
- data/doc/users_guide_snippets/appendix_c_spawning_methods.txt +0 -36
- data/doc/users_guide_snippets/deployment_basics.txt +0 -37
- data/doc/users_guide_snippets/enterprise_only.txt +0 -1
- data/doc/users_guide_snippets/environment_variables.txt +0 -44
- data/doc/users_guide_snippets/global_queueing_explained.txt +0 -74
- data/doc/users_guide_snippets/installation.txt +0 -228
- data/doc/users_guide_snippets/installation/run_installer.txt +0 -58
- data/doc/users_guide_snippets/installation/verify_running_epilogue.txt +0 -6
- data/doc/users_guide_snippets/passenger_spawn_method.txt +0 -37
- data/doc/users_guide_snippets/rackup_specifications.txt +0 -1
- data/doc/users_guide_snippets/rvm_helper_tool.txt +0 -44
- data/doc/users_guide_snippets/since_version.txt +0 -1
- data/doc/users_guide_snippets/support_information.txt +0 -8
- data/doc/users_guide_snippets/tips.txt +0 -302
- data/doc/users_guide_snippets/troubleshooting/default.txt +0 -48
- data/doc/users_guide_snippets/troubleshooting/rails.txt +0 -59
- data/doc/users_guide_snippets/under_the_hood/page_caching_support.txt +0 -24
- data/doc/users_guide_snippets/under_the_hood/relationship_with_ruby.txt +0 -10
- data/doc/users_guide_snippets/where_to_get_support.txt +0 -9
- data/src/agent/Shared/Base.cpp +0 -1678
- data/src/agent/UstRouter/ApiServer.h +0 -292
- data/src/agent/UstRouter/Client.h +0 -112
- data/src/agent/UstRouter/Controller.h +0 -1309
- data/src/agent/UstRouter/LogSink.h +0 -145
- data/src/agent/UstRouter/OptionParser.h +0 -180
- data/src/agent/UstRouter/RemoteSender.h +0 -853
- data/src/agent/UstRouter/RemoteSink.h +0 -145
- data/src/agent/UstRouter/Transaction.h +0 -278
- data/src/agent/UstRouter/UstRouterMain.cpp +0 -681
- data/src/agent/Watchdog/UstRouterWatcher.cpp +0 -80
- data/src/ruby_supportlib/phusion_passenger/platform_info/macos.rb +0 -45
@@ -0,0 +1,63 @@
|
|
1
|
+
/*
|
2
|
+
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
+
* Copyright (c) 2010-2017 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_AGENT_FUNDAMENTALS_ABORT_HANDLER_H_
|
27
|
+
#define _PASSENGER_AGENT_FUNDAMENTALS_ABORT_HANDLER_H_
|
28
|
+
|
29
|
+
namespace Passenger {
|
30
|
+
class ResourceLocator;
|
31
|
+
}
|
32
|
+
|
33
|
+
namespace Passenger {
|
34
|
+
namespace Agent {
|
35
|
+
namespace Fundamentals {
|
36
|
+
|
37
|
+
|
38
|
+
struct AbortHandlerConfig {
|
39
|
+
typedef void (*DiagnosticsDumper)(void *userData);
|
40
|
+
|
41
|
+
char *ruby;
|
42
|
+
char **origArgv;
|
43
|
+
unsigned int randomSeed;
|
44
|
+
bool dumpWithCrashWatch;
|
45
|
+
bool beep;
|
46
|
+
bool stopProcess;
|
47
|
+
ResourceLocator *resourceLocator;
|
48
|
+
DiagnosticsDumper diagnosticsDumper;
|
49
|
+
void *diagnosticsDumperUserData;
|
50
|
+
};
|
51
|
+
|
52
|
+
void installAbortHandler(const AbortHandlerConfig *config);
|
53
|
+
bool abortHandlerInstalled();
|
54
|
+
void abortHandlerLogFds();
|
55
|
+
void abortHandlerConfigChanged();
|
56
|
+
void shutdownAbortHandler();
|
57
|
+
|
58
|
+
|
59
|
+
} // namespace Fundamentals
|
60
|
+
} // namespace Agent
|
61
|
+
} // namespace Passenger
|
62
|
+
|
63
|
+
#endif /* _PASSENGER_AGENT_FUNDAMENTALS_ABORT_HANDLER_H_ */
|
@@ -0,0 +1,614 @@
|
|
1
|
+
/*
|
2
|
+
* Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
+
* Copyright (c) 2010-2017 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
|
+
#ifndef _GNU_SOURCE
|
28
|
+
#define _GNU_SOURCE
|
29
|
+
#endif
|
30
|
+
|
31
|
+
#include <Shared/Fundamentals/Initialization.h>
|
32
|
+
#include <Shared/Fundamentals/AbortHandler.h>
|
33
|
+
#include <Shared/Fundamentals/Utils.h>
|
34
|
+
|
35
|
+
#include <oxt/initialize.hpp>
|
36
|
+
#include <oxt/backtrace.hpp>
|
37
|
+
#include <string>
|
38
|
+
#include <vector>
|
39
|
+
|
40
|
+
#include <sys/types.h>
|
41
|
+
#include <stdlib.h> // for srandom()
|
42
|
+
#include <unistd.h>
|
43
|
+
#include <signal.h>
|
44
|
+
#include <cstdio>
|
45
|
+
#include <cstdlib>
|
46
|
+
#include <cstring>
|
47
|
+
#include <cassert>
|
48
|
+
|
49
|
+
#include <Exceptions.h>
|
50
|
+
#include <ResourceLocator.h>
|
51
|
+
#include <LoggingKit/LoggingKit.h>
|
52
|
+
#include <LoggingKit/Context.h>
|
53
|
+
#include <Utils/StrIntUtils.h>
|
54
|
+
#include <Utils/MessageIO.h>
|
55
|
+
#include <Utils/SystemTime.h>
|
56
|
+
|
57
|
+
|
58
|
+
namespace Passenger {
|
59
|
+
namespace Agent {
|
60
|
+
namespace Fundamentals {
|
61
|
+
|
62
|
+
using namespace std;
|
63
|
+
|
64
|
+
|
65
|
+
Context *context = NULL;
|
66
|
+
|
67
|
+
|
68
|
+
bool
|
69
|
+
feedbackFdAvailable() {
|
70
|
+
return context->feedbackFdAvailable;
|
71
|
+
}
|
72
|
+
|
73
|
+
static int
|
74
|
+
lookupErrno(const char *name) {
|
75
|
+
struct Entry {
|
76
|
+
int errorCode;
|
77
|
+
const char * const name;
|
78
|
+
};
|
79
|
+
static const Entry entries[] = {
|
80
|
+
{ EPERM, "EPERM" },
|
81
|
+
{ ENOENT, "ENOENT" },
|
82
|
+
{ ESRCH, "ESRCH" },
|
83
|
+
{ EINTR, "EINTR" },
|
84
|
+
{ EBADF, "EBADF" },
|
85
|
+
{ ENOMEM, "ENOMEM" },
|
86
|
+
{ EACCES, "EACCES" },
|
87
|
+
{ EBUSY, "EBUSY" },
|
88
|
+
{ EEXIST, "EEXIST" },
|
89
|
+
{ ENOTDIR, "ENOTDIR" },
|
90
|
+
{ EISDIR, "EISDIR" },
|
91
|
+
{ EINVAL, "EINVAL" },
|
92
|
+
{ ENFILE, "ENFILE" },
|
93
|
+
{ EMFILE, "EMFILE" },
|
94
|
+
{ ENOTTY, "ENOTTY" },
|
95
|
+
{ ETXTBSY, "ETXTBSY" },
|
96
|
+
{ ENOSPC, "ENOSPC" },
|
97
|
+
{ ESPIPE, "ESPIPE" },
|
98
|
+
{ EMLINK, "EMLINK" },
|
99
|
+
{ EPIPE, "EPIPE" },
|
100
|
+
{ EAGAIN, "EAGAIN" },
|
101
|
+
{ EWOULDBLOCK, "EWOULDBLOCK" },
|
102
|
+
{ EINPROGRESS, "EINPROGRESS" },
|
103
|
+
{ EADDRINUSE, "EADDRINUSE" },
|
104
|
+
{ EADDRNOTAVAIL, "EADDRNOTAVAIL" },
|
105
|
+
{ ENETUNREACH, "ENETUNREACH" },
|
106
|
+
{ ECONNABORTED, "ECONNABORTED" },
|
107
|
+
{ ECONNRESET, "ECONNRESET" },
|
108
|
+
{ EISCONN, "EISCONN" },
|
109
|
+
{ ENOTCONN, "ENOTCONN" },
|
110
|
+
{ ETIMEDOUT, "ETIMEDOUT" },
|
111
|
+
{ ECONNREFUSED, "ECONNREFUSED" },
|
112
|
+
{ EHOSTDOWN, "EHOSTDOWN" },
|
113
|
+
{ EHOSTUNREACH, "EHOSTUNREACH" },
|
114
|
+
#ifdef EIO
|
115
|
+
{ EIO, "EIO" },
|
116
|
+
#endif
|
117
|
+
#ifdef ENXIO
|
118
|
+
{ ENXIO, "ENXIO" },
|
119
|
+
#endif
|
120
|
+
#ifdef E2BIG
|
121
|
+
{ E2BIG, "E2BIG" },
|
122
|
+
#endif
|
123
|
+
#ifdef ENOEXEC
|
124
|
+
{ ENOEXEC, "ENOEXEC" },
|
125
|
+
#endif
|
126
|
+
#ifdef ECHILD
|
127
|
+
{ ECHILD, "ECHILD" },
|
128
|
+
#endif
|
129
|
+
#ifdef EDEADLK
|
130
|
+
{ EDEADLK, "EDEADLK" },
|
131
|
+
#endif
|
132
|
+
#ifdef EFAULT
|
133
|
+
{ EFAULT, "EFAULT" },
|
134
|
+
#endif
|
135
|
+
#ifdef ENOTBLK
|
136
|
+
{ ENOTBLK, "ENOTBLK" },
|
137
|
+
#endif
|
138
|
+
#ifdef EXDEV
|
139
|
+
{ EXDEV, "EXDEV" },
|
140
|
+
#endif
|
141
|
+
#ifdef ENODEV
|
142
|
+
{ ENODEV, "ENODEV" },
|
143
|
+
#endif
|
144
|
+
#ifdef EFBIG
|
145
|
+
{ EFBIG, "EFBIG" },
|
146
|
+
#endif
|
147
|
+
#ifdef EROFS
|
148
|
+
{ EROFS, "EROFS" },
|
149
|
+
#endif
|
150
|
+
#ifdef EDOM
|
151
|
+
{ EDOM, "EDOM" },
|
152
|
+
#endif
|
153
|
+
#ifdef ERANGE
|
154
|
+
{ ERANGE, "ERANGE" },
|
155
|
+
#endif
|
156
|
+
#ifdef EALREADY
|
157
|
+
{ EALREADY, "EALREADY" },
|
158
|
+
#endif
|
159
|
+
#ifdef ENOTSOCK
|
160
|
+
{ ENOTSOCK, "ENOTSOCK" },
|
161
|
+
#endif
|
162
|
+
#ifdef EDESTADDRREQ
|
163
|
+
{ EDESTADDRREQ, "EDESTADDRREQ" },
|
164
|
+
#endif
|
165
|
+
#ifdef EMSGSIZE
|
166
|
+
{ EMSGSIZE, "EMSGSIZE" },
|
167
|
+
#endif
|
168
|
+
#ifdef EPROTOTYPE
|
169
|
+
{ EPROTOTYPE, "EPROTOTYPE" },
|
170
|
+
#endif
|
171
|
+
#ifdef ENOPROTOOPT
|
172
|
+
{ ENOPROTOOPT, "ENOPROTOOPT" },
|
173
|
+
#endif
|
174
|
+
#ifdef EPROTONOSUPPORT
|
175
|
+
{ EPROTONOSUPPORT, "EPROTONOSUPPORT" },
|
176
|
+
#endif
|
177
|
+
#ifdef ESOCKTNOSUPPORT
|
178
|
+
{ ESOCKTNOSUPPORT, "ESOCKTNOSUPPORT" },
|
179
|
+
#endif
|
180
|
+
#ifdef ENOTSUP
|
181
|
+
{ ENOTSUP, "ENOTSUP" },
|
182
|
+
#endif
|
183
|
+
#ifdef EOPNOTSUPP
|
184
|
+
{ EOPNOTSUPP, "EOPNOTSUPP" },
|
185
|
+
#endif
|
186
|
+
#ifdef EPFNOSUPPORT
|
187
|
+
{ EPFNOSUPPORT, "EPFNOSUPPORT" },
|
188
|
+
#endif
|
189
|
+
#ifdef EAFNOSUPPORT
|
190
|
+
{ EAFNOSUPPORT, "EAFNOSUPPORT" },
|
191
|
+
#endif
|
192
|
+
#ifdef ENETDOWN
|
193
|
+
{ ENETDOWN, "ENETDOWN" },
|
194
|
+
#endif
|
195
|
+
#ifdef ENETRESET
|
196
|
+
{ ENETRESET, "ENETRESET" },
|
197
|
+
#endif
|
198
|
+
#ifdef ENOBUFS
|
199
|
+
{ ENOBUFS, "ENOBUFS" },
|
200
|
+
#endif
|
201
|
+
#ifdef ESHUTDOWN
|
202
|
+
{ ESHUTDOWN, "ESHUTDOWN" },
|
203
|
+
#endif
|
204
|
+
#ifdef ETOOMANYREFS
|
205
|
+
{ ETOOMANYREFS, "ETOOMANYREFS" },
|
206
|
+
#endif
|
207
|
+
#ifdef ELOOP
|
208
|
+
{ ELOOP, "ELOOP" },
|
209
|
+
#endif
|
210
|
+
#ifdef ENAMETOOLONG
|
211
|
+
{ ENAMETOOLONG, "ENAMETOOLONG" },
|
212
|
+
#endif
|
213
|
+
#ifdef ENOTEMPTY
|
214
|
+
{ ENOTEMPTY, "ENOTEMPTY" },
|
215
|
+
#endif
|
216
|
+
#ifdef EPROCLIM
|
217
|
+
{ EPROCLIM, "EPROCLIM" },
|
218
|
+
#endif
|
219
|
+
#ifdef EUSERS
|
220
|
+
{ EUSERS, "EUSERS" },
|
221
|
+
#endif
|
222
|
+
#ifdef EDQUOT
|
223
|
+
{ EDQUOT, "EDQUOT" },
|
224
|
+
#endif
|
225
|
+
#ifdef ESTALE
|
226
|
+
{ ESTALE, "ESTALE" },
|
227
|
+
#endif
|
228
|
+
#ifdef EREMOTE
|
229
|
+
{ EREMOTE, "EREMOTE" },
|
230
|
+
#endif
|
231
|
+
#ifdef EBADRPC
|
232
|
+
{ EBADRPC, "EBADRPC" },
|
233
|
+
#endif
|
234
|
+
#ifdef ERPCMISMATCH
|
235
|
+
{ ERPCMISMATCH, "ERPCMISMATCH" },
|
236
|
+
#endif
|
237
|
+
#ifdef EPROGUNAVAIL
|
238
|
+
{ EPROGUNAVAIL, "EPROGUNAVAIL" },
|
239
|
+
#endif
|
240
|
+
#ifdef EPROGMISMATCH
|
241
|
+
{ EPROGMISMATCH, "EPROGMISMATCH" },
|
242
|
+
#endif
|
243
|
+
#ifdef EPROCUNAVAIL
|
244
|
+
{ EPROCUNAVAIL, "EPROCUNAVAIL" },
|
245
|
+
#endif
|
246
|
+
#ifdef ENOLCK
|
247
|
+
{ ENOLCK, "ENOLCK" },
|
248
|
+
#endif
|
249
|
+
#ifdef ENOSYS
|
250
|
+
{ ENOSYS, "ENOSYS" },
|
251
|
+
#endif
|
252
|
+
#ifdef EFTYPE
|
253
|
+
{ EFTYPE, "EFTYPE" },
|
254
|
+
#endif
|
255
|
+
#ifdef EAUTH
|
256
|
+
{ EAUTH, "EAUTH" },
|
257
|
+
#endif
|
258
|
+
#ifdef ENEEDAUTH
|
259
|
+
{ ENEEDAUTH, "ENEEDAUTH" },
|
260
|
+
#endif
|
261
|
+
#ifdef EPWROFF
|
262
|
+
{ EPWROFF, "EPWROFF" },
|
263
|
+
#endif
|
264
|
+
#ifdef EDEVERR
|
265
|
+
{ EDEVERR, "EDEVERR" },
|
266
|
+
#endif
|
267
|
+
#ifdef EOVERFLOW
|
268
|
+
{ EOVERFLOW, "EOVERFLOW" },
|
269
|
+
#endif
|
270
|
+
#ifdef EBADEXEC
|
271
|
+
{ EBADEXEC, "EBADEXEC" },
|
272
|
+
#endif
|
273
|
+
#ifdef EBADARCH
|
274
|
+
{ EBADARCH, "EBADARCH" },
|
275
|
+
#endif
|
276
|
+
#ifdef ESHLIBVERS
|
277
|
+
{ ESHLIBVERS, "ESHLIBVERS" },
|
278
|
+
#endif
|
279
|
+
#ifdef EBADMACHO
|
280
|
+
{ EBADMACHO, "EBADMACHO" },
|
281
|
+
#endif
|
282
|
+
#ifdef ECANCELED
|
283
|
+
{ ECANCELED, "ECANCELED" },
|
284
|
+
#endif
|
285
|
+
#ifdef EIDRM
|
286
|
+
{ EIDRM, "EIDRM" },
|
287
|
+
#endif
|
288
|
+
#ifdef ENOMSG
|
289
|
+
{ ENOMSG, "ENOMSG" },
|
290
|
+
#endif
|
291
|
+
#ifdef EILSEQ
|
292
|
+
{ EILSEQ, "EILSEQ" },
|
293
|
+
#endif
|
294
|
+
#ifdef ENOATTR
|
295
|
+
{ ENOATTR, "ENOATTR" },
|
296
|
+
#endif
|
297
|
+
#ifdef EBADMSG
|
298
|
+
{ EBADMSG, "EBADMSG" },
|
299
|
+
#endif
|
300
|
+
#ifdef EMULTIHOP
|
301
|
+
{ EMULTIHOP, "EMULTIHOP" },
|
302
|
+
#endif
|
303
|
+
#ifdef ENODATA
|
304
|
+
{ ENODATA, "ENODATA" },
|
305
|
+
#endif
|
306
|
+
#ifdef ENOLINK
|
307
|
+
{ ENOLINK, "ENOLINK" },
|
308
|
+
#endif
|
309
|
+
#ifdef ENOSR
|
310
|
+
{ ENOSR, "ENOSR" },
|
311
|
+
#endif
|
312
|
+
#ifdef ENOSTR
|
313
|
+
{ ENOSTR, "ENOSTR" },
|
314
|
+
#endif
|
315
|
+
#ifdef EPROTO
|
316
|
+
{ EPROTO, "EPROTO" },
|
317
|
+
#endif
|
318
|
+
#ifdef ETIME
|
319
|
+
{ ETIME, "ETIME" },
|
320
|
+
#endif
|
321
|
+
#ifdef EOPNOTSUPP
|
322
|
+
{ EOPNOTSUPP, "EOPNOTSUPP" },
|
323
|
+
#endif
|
324
|
+
#ifdef ENOPOLICY
|
325
|
+
{ ENOPOLICY, "ENOPOLICY" },
|
326
|
+
#endif
|
327
|
+
#ifdef ENOTRECOVERABLE
|
328
|
+
{ ENOTRECOVERABLE, "ENOTRECOVERABLE" },
|
329
|
+
#endif
|
330
|
+
#ifdef EOWNERDEAD
|
331
|
+
{ EOWNERDEAD, "EOWNERDEAD" },
|
332
|
+
#endif
|
333
|
+
};
|
334
|
+
|
335
|
+
for (unsigned int i = 0; i < sizeof(entries) / sizeof(Entry); i++) {
|
336
|
+
if (strcmp(entries[i].name, name) == 0) {
|
337
|
+
return entries[i].errorCode;
|
338
|
+
}
|
339
|
+
}
|
340
|
+
return -1;
|
341
|
+
}
|
342
|
+
|
343
|
+
static void
|
344
|
+
initializeSyscallFailureSimulation(const char *processName) {
|
345
|
+
// Format:
|
346
|
+
// PassengerAgent watchdog=EMFILE:0.1,ECONNREFUSED:0.25;PassengerAgent core=ESPIPE=0.4
|
347
|
+
const char *spec = getenv("PASSENGER_SIMULATE_SYSCALL_FAILURES");
|
348
|
+
string prefix = string(processName) + "=";
|
349
|
+
vector<string> components;
|
350
|
+
unsigned int i;
|
351
|
+
|
352
|
+
// Lookup this process in the specification string.
|
353
|
+
split(spec, ';', components);
|
354
|
+
for (i = 0; i < components.size(); i++) {
|
355
|
+
if (startsWith(components[i], prefix)) {
|
356
|
+
// Found!
|
357
|
+
string value = components[i].substr(prefix.size());
|
358
|
+
split(value, ',', components);
|
359
|
+
vector<string> keyAndValue;
|
360
|
+
vector<ErrorChance> chances;
|
361
|
+
|
362
|
+
// Process each errorCode:chance pair.
|
363
|
+
for (i = 0; i < components.size(); i++) {
|
364
|
+
split(components[i], ':', keyAndValue);
|
365
|
+
if (keyAndValue.size() != 2) {
|
366
|
+
fprintf(stderr, "%s: invalid syntax in PASSENGER_SIMULATE_SYSCALL_FAILURES: '%s'\n",
|
367
|
+
processName, components[i].c_str());
|
368
|
+
continue;
|
369
|
+
}
|
370
|
+
|
371
|
+
int e = lookupErrno(keyAndValue[0].c_str());
|
372
|
+
if (e == -1) {
|
373
|
+
fprintf(stderr, "%s: invalid error code in PASSENGER_SIMULATE_SYSCALL_FAILURES: '%s'\n",
|
374
|
+
processName, components[i].c_str());
|
375
|
+
continue;
|
376
|
+
}
|
377
|
+
|
378
|
+
ErrorChance chance;
|
379
|
+
chance.chance = atof(keyAndValue[1].c_str());
|
380
|
+
if (chance.chance < 0 || chance.chance > 1) {
|
381
|
+
fprintf(stderr, "%s: invalid chance PASSENGER_SIMULATE_SYSCALL_FAILURES: '%s' - chance must be between 0 and 1\n",
|
382
|
+
processName, components[i].c_str());
|
383
|
+
continue;
|
384
|
+
}
|
385
|
+
chance.errorCode = e;
|
386
|
+
chances.push_back(chance);
|
387
|
+
}
|
388
|
+
|
389
|
+
// Install the chances.
|
390
|
+
setup_random_failure_simulation(&chances[0], chances.size());
|
391
|
+
return;
|
392
|
+
}
|
393
|
+
}
|
394
|
+
}
|
395
|
+
|
396
|
+
static bool
|
397
|
+
isBlank(const char *str) {
|
398
|
+
while (*str != '\0') {
|
399
|
+
if (*str != ' ') {
|
400
|
+
return false;
|
401
|
+
}
|
402
|
+
str++;
|
403
|
+
}
|
404
|
+
return true;
|
405
|
+
}
|
406
|
+
|
407
|
+
static bool
|
408
|
+
extraArgumentsPassed(int argc, char *argv[], int argStartIndex) {
|
409
|
+
assert(argc >= argStartIndex);
|
410
|
+
return argc > argStartIndex + 1
|
411
|
+
// Allow the Watchdog to pass an all-whitespace argument. This
|
412
|
+
// argument provides the memory space for us to change the process title.
|
413
|
+
|| (argc == argStartIndex + 1 && !isBlank(argv[argStartIndex]));
|
414
|
+
}
|
415
|
+
|
416
|
+
static void
|
417
|
+
maybeInitializeAbortHandler() {
|
418
|
+
if (!getEnvBool("PASSENGER_ABORT_HANDLER", true)) {
|
419
|
+
return;
|
420
|
+
}
|
421
|
+
|
422
|
+
AbortHandlerConfig *config = &context->abortHandlerConfig;
|
423
|
+
|
424
|
+
config->origArgv = context->origArgv;
|
425
|
+
config->randomSeed = context->randomSeed;
|
426
|
+
config->dumpWithCrashWatch = getEnvBool("PASSENGER_DUMP_WITH_CRASH_WATCH", true);
|
427
|
+
config->beep = getEnvBool("PASSENGER_BEEP_ON_ABORT");
|
428
|
+
config->stopProcess = getEnvBool("PASSENGER_STOP_ON_ABORT");
|
429
|
+
|
430
|
+
installAbortHandler(config);
|
431
|
+
}
|
432
|
+
|
433
|
+
static void
|
434
|
+
maybeInitializeSyscallFailureSimulation(const char *processName) {
|
435
|
+
if (getEnvBool("PASSENGER_SIMULATE_SYSCALL_FAILURES")) {
|
436
|
+
initializeSyscallFailureSimulation(processName);
|
437
|
+
}
|
438
|
+
}
|
439
|
+
|
440
|
+
static void
|
441
|
+
initializeLoggingKit(const char *processName, VariantMap &options) {
|
442
|
+
Json::Value config(Json::objectValue);
|
443
|
+
|
444
|
+
options.setDefaultInt("log_level", DEFAULT_LOG_LEVEL);
|
445
|
+
config["level"] = options.get("log_level");
|
446
|
+
|
447
|
+
if (options.has("log_file")) {
|
448
|
+
config["target"] = options.get("log_file");
|
449
|
+
} else if (options.has("debug_log_file")) {
|
450
|
+
config["target"] = options.get("debug_log_file");
|
451
|
+
}
|
452
|
+
|
453
|
+
if (options.has("file_descriptor_log_file")) {
|
454
|
+
config["file_descriptor_log_target"] =
|
455
|
+
options.get("file_descriptor_log_file");
|
456
|
+
}
|
457
|
+
|
458
|
+
LoggingKit::initialize(config);
|
459
|
+
|
460
|
+
if (options.has("file_descriptor_log_file")) {
|
461
|
+
// This information helps ./dev/parse_file_descriptor_log.
|
462
|
+
FastStringStream<> stream;
|
463
|
+
LoggingKit::_prepareLogEntry(stream, LoggingKit::CRIT, __FILE__, __LINE__);
|
464
|
+
stream << "Starting agent: " << processName << "\n";
|
465
|
+
_writeFileDescriptorLogEntry(LoggingKit::context->getConfigRealization(),
|
466
|
+
stream.data(), stream.size());
|
467
|
+
|
468
|
+
config = LoggingKit::context->getConfig().inspect();
|
469
|
+
P_LOG_FILE_DESCRIPTOR_OPEN4(
|
470
|
+
LoggingKit::context->getConfigRealization()->fileDescriptorLogTargetFd,
|
471
|
+
__FILE__, __LINE__,
|
472
|
+
"file descriptor log file "
|
473
|
+
<< config["file_descriptor_log_target"]["effective_value"]["path"].asString());
|
474
|
+
} else {
|
475
|
+
// This information helps ./dev/parse_file_descriptor_log.
|
476
|
+
P_DEBUG("Starting agent: " << processName);
|
477
|
+
}
|
478
|
+
|
479
|
+
if (getEnvBool("PASSENGER_USE_FEEDBACK_FD")) {
|
480
|
+
P_LOG_FILE_DESCRIPTOR_OPEN2(FEEDBACK_FD, "feedback FD");
|
481
|
+
}
|
482
|
+
if (abortHandlerInstalled()) {
|
483
|
+
abortHandlerLogFds();
|
484
|
+
}
|
485
|
+
}
|
486
|
+
|
487
|
+
static void
|
488
|
+
storeArgvCopy(int argc, char *argv[]) {
|
489
|
+
// Make a copy of the arguments before changing process title.
|
490
|
+
context->origArgc = argc;
|
491
|
+
context->origArgv = (char **) malloc(argc * sizeof(char *));
|
492
|
+
for (int i = 0; i < argc; i++) {
|
493
|
+
context->origArgv[i] = strdup(argv[i]);
|
494
|
+
}
|
495
|
+
}
|
496
|
+
|
497
|
+
static void
|
498
|
+
changeProcessTitle(int argc, char **argv[], const char *processName) {
|
499
|
+
size_t totalArgLen = strlen((*argv)[0]);
|
500
|
+
for (int i = 1; i < argc; i++) {
|
501
|
+
size_t len = strlen((*argv)[i]);
|
502
|
+
totalArgLen += len + 1;
|
503
|
+
memset((*argv)[i], '\0', len);
|
504
|
+
}
|
505
|
+
strncpy((*argv)[0], processName, totalArgLen);
|
506
|
+
*argv = context->origArgv;
|
507
|
+
}
|
508
|
+
|
509
|
+
VariantMap
|
510
|
+
initializeAgent(int argc, char **argv[], const char *processName,
|
511
|
+
OptionParserFunc optionParser, PreinitializationFunc preinit,
|
512
|
+
int argStartIndex)
|
513
|
+
{
|
514
|
+
VariantMap options;
|
515
|
+
const char *seedStr;
|
516
|
+
|
517
|
+
context = new Context();
|
518
|
+
memset(context, 0, sizeof(Context));
|
519
|
+
|
520
|
+
seedStr = getEnvString("PASSENGER_RANDOM_SEED");
|
521
|
+
if (seedStr == NULL) {
|
522
|
+
context->randomSeed = (unsigned int) time(NULL);
|
523
|
+
} else {
|
524
|
+
context->randomSeed = (unsigned int) atoll(seedStr);
|
525
|
+
}
|
526
|
+
srand(context->randomSeed);
|
527
|
+
srandom(context->randomSeed);
|
528
|
+
|
529
|
+
ignoreSigpipe();
|
530
|
+
maybeInitializeAbortHandler();
|
531
|
+
oxt::initialize();
|
532
|
+
setup_syscall_interruption_support();
|
533
|
+
maybeInitializeSyscallFailureSimulation(processName);
|
534
|
+
SystemTime::initialize();
|
535
|
+
setvbuf(stdout, NULL, _IONBF, 0);
|
536
|
+
setvbuf(stderr, NULL, _IONBF, 0);
|
537
|
+
|
538
|
+
TRACE_POINT();
|
539
|
+
try {
|
540
|
+
if (getEnvBool("PASSENGER_USE_FEEDBACK_FD")) {
|
541
|
+
if (extraArgumentsPassed(argc, *argv, argStartIndex)) {
|
542
|
+
fprintf(stderr, "No arguments may be passed when using the feedback FD.\n");
|
543
|
+
exit(1);
|
544
|
+
}
|
545
|
+
context->feedbackFdAvailable = true;
|
546
|
+
options.readFrom(FEEDBACK_FD);
|
547
|
+
} else if (optionParser != NULL) {
|
548
|
+
optionParser(argc, (const char **) *argv, options);
|
549
|
+
} else {
|
550
|
+
options.readFrom((const char **) *argv + argStartIndex,
|
551
|
+
argc - argStartIndex);
|
552
|
+
}
|
553
|
+
|
554
|
+
if (options.has("passenger_root")) {
|
555
|
+
context->resourceLocator = new ResourceLocator(options.get("passenger_root", true));
|
556
|
+
if (abortHandlerInstalled()) {
|
557
|
+
context->abortHandlerConfig.ruby = strdup(options.get("default_ruby", false, DEFAULT_RUBY).c_str());
|
558
|
+
context->abortHandlerConfig.resourceLocator = context->resourceLocator;
|
559
|
+
abortHandlerConfigChanged();
|
560
|
+
}
|
561
|
+
}
|
562
|
+
|
563
|
+
if (preinit != NULL) {
|
564
|
+
preinit(options);
|
565
|
+
}
|
566
|
+
|
567
|
+
initializeLoggingKit(processName, options);
|
568
|
+
} catch (const tracable_exception &e) {
|
569
|
+
P_ERROR("*** ERROR: " << e.what() << "\n" << e.backtrace());
|
570
|
+
exit(1);
|
571
|
+
}
|
572
|
+
|
573
|
+
storeArgvCopy(argc, *argv);
|
574
|
+
changeProcessTitle(argc, argv, processName);
|
575
|
+
|
576
|
+
P_DEBUG("Random seed: " << context->randomSeed);
|
577
|
+
|
578
|
+
return options;
|
579
|
+
}
|
580
|
+
|
581
|
+
void
|
582
|
+
shutdownAgent(VariantMap *agentOptions) {
|
583
|
+
delete agentOptions;
|
584
|
+
LoggingKit::shutdown();
|
585
|
+
oxt::shutdown();
|
586
|
+
if (abortHandlerInstalled()) {
|
587
|
+
shutdownAbortHandler();
|
588
|
+
free(context->abortHandlerConfig.ruby);
|
589
|
+
}
|
590
|
+
for (int i = 0; i < context->origArgc; i++) {
|
591
|
+
free(context->origArgv[i]);
|
592
|
+
}
|
593
|
+
free(context->origArgv);
|
594
|
+
delete context->resourceLocator;
|
595
|
+
delete context;
|
596
|
+
context = NULL;
|
597
|
+
}
|
598
|
+
|
599
|
+
void
|
600
|
+
restoreOomScore(VariantMap *agentOptions) {
|
601
|
+
string score = agentOptions->get("original_oom_score", false);
|
602
|
+
bool isLegacy;
|
603
|
+
int ret = tryRestoreOomScore(score, isLegacy);
|
604
|
+
if (ret != 0) {
|
605
|
+
P_WARN("Unable to set OOM score to " << score << " (legacy: " << isLegacy
|
606
|
+
<< ") due to error: " << strerror(ret)
|
607
|
+
<< " (process will remain at inherited OOM score)");
|
608
|
+
}
|
609
|
+
}
|
610
|
+
|
611
|
+
|
612
|
+
} // namespace Fundamentals
|
613
|
+
} // namespace Agent
|
614
|
+
} // namespace Passenger
|