passenger 4.0.14 → 4.0.16
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.
- data.tar.gz.asc +7 -7
- data/NEWS +69 -0
- data/bin/passenger-install-apache2-module +7 -1
- data/bin/passenger-install-nginx-module +18 -1
- data/build/apache2.rb +25 -1
- data/build/basics.rb +7 -4
- data/build/debian.rb +72 -25
- data/build/nginx.rb +24 -0
- data/build/packaging.rb +45 -3
- data/debian.template/{control → control.template} +17 -8
- data/debian.template/ruby-passenger.install.template +1 -0
- data/debian.template/rules.template +9 -3
- data/dev/run_travis.sh +14 -0
- data/doc/Users guide Apache.idmap.txt +64 -48
- data/doc/Users guide Apache.txt +127 -93
- data/doc/Users guide Nginx.idmap.txt +46 -28
- data/doc/Users guide Nginx.txt +100 -12
- data/doc/images/{conservative_spawning.png → direct_spawning.png} +0 -0
- data/doc/images/{conservative_spawning.svg → direct_spawning.svg} +0 -0
- data/doc/users_guide_snippets/installation.txt +107 -66
- data/doc/users_guide_snippets/passenger_spawn_method.txt +1 -1
- data/doc/users_guide_snippets/rvm_helper_tool.txt +0 -12
- data/doc/users_guide_snippets/tips.txt +70 -3
- data/doc/users_guide_snippets/under_the_hood/page_caching_support.txt +2 -0
- data/doc/users_guide_snippets/under_the_hood/relationship_with_ruby.txt +114 -0
- data/ext/apache2/Configuration.cpp +53 -101
- data/ext/apache2/Configuration.hpp +19 -41
- data/ext/apache2/ConfigurationCommands.cpp +95 -0
- data/ext/apache2/ConfigurationCommands.cpp.erb +91 -0
- data/ext/apache2/ConfigurationFields.hpp +59 -0
- data/ext/apache2/ConfigurationFields.hpp.erb +89 -0
- data/ext/apache2/ConfigurationSetters.cpp +223 -0
- data/ext/apache2/ConfigurationSetters.cpp.erb +126 -0
- data/ext/apache2/CreateDirConfig.cpp +50 -0
- data/ext/apache2/CreateDirConfig.cpp.erb +71 -0
- data/ext/apache2/Hooks.cpp +6 -0
- data/ext/apache2/MergeDirConfig.cpp +103 -0
- data/ext/apache2/MergeDirConfig.cpp.erb +81 -0
- data/ext/common/ApplicationPool2/AppTypes.cpp +2 -0
- data/ext/common/ApplicationPool2/AppTypes.h +2 -0
- data/ext/common/ApplicationPool2/Common.h +1 -1
- data/ext/common/ApplicationPool2/Group.h +56 -7
- data/ext/common/ApplicationPool2/Implementation.cpp +133 -31
- data/ext/common/ApplicationPool2/Options.h +23 -2
- data/ext/common/ApplicationPool2/Pool.h +8 -1
- data/ext/common/ApplicationPool2/Process.h +9 -0
- data/ext/common/ApplicationPool2/Session.h +1 -0
- data/ext/common/ApplicationPool2/Spawner.h +21 -19
- data/ext/common/ApplicationPool2/SuperGroup.h +1 -1
- data/ext/common/Constants.h +21 -17
- data/ext/common/Constants.h.erb +1 -1
- data/ext/common/Exceptions.h +19 -0
- data/ext/common/ServerInstanceDir.h +8 -4
- data/ext/common/Utils.cpp +33 -1
- data/ext/common/Utils.h +14 -0
- data/ext/common/Utils/StrIntUtils.cpp +16 -0
- data/ext/common/Utils/StrIntUtils.h +5 -0
- data/ext/common/agents/HelperAgent/Main.cpp +5 -5
- data/ext/common/agents/HelperAgent/RequestHandler.h +94 -45
- data/ext/common/agents/LoggingAgent/Main.cpp +10 -26
- data/ext/common/agents/Watchdog/Main.cpp +4 -15
- data/ext/nginx/CacheLocationConfig.c +501 -0
- data/ext/nginx/CacheLocationConfig.c.erb +140 -0
- data/ext/nginx/Configuration.c +29 -453
- data/ext/nginx/Configuration.h +3 -21
- data/ext/nginx/ConfigurationCommands.c +501 -0
- data/ext/nginx/ConfigurationCommands.c.erb +136 -0
- data/ext/nginx/ConfigurationFields.h +89 -0
- data/ext/nginx/ConfigurationFields.h.erb +85 -0
- data/ext/nginx/ContentHandler.c +3 -166
- data/ext/nginx/CreateLocationConfig.c +146 -0
- data/ext/nginx/CreateLocationConfig.c.erb +70 -0
- data/ext/nginx/MergeLocationConfig.c +166 -0
- data/ext/nginx/MergeLocationConfig.c.erb +72 -0
- data/ext/nginx/config +4 -0
- data/ext/oxt/detail/tracable_exception_disabled.hpp +21 -1
- data/ext/oxt/detail/tracable_exception_enabled.hpp +4 -1
- data/ext/oxt/implementation.cpp +7 -1
- data/ext/oxt/macros.hpp +9 -7
- data/helper-scripts/backtrace-sanitizer.rb +23 -0
- data/helper-scripts/classic-rails-loader.rb +23 -0
- data/helper-scripts/classic-rails-preloader.rb +23 -0
- data/helper-scripts/download_binaries/extconf.rb +10 -5
- data/helper-scripts/meteor-loader.rb +127 -0
- data/helper-scripts/node-loader.js +1 -1
- data/helper-scripts/rack-preloader.rb +23 -0
- data/helper-scripts/system-memory-stats.py +22 -0
- data/helper-scripts/touch-dir.sh +48 -0
- data/lib/phusion_passenger.rb +1 -1
- data/lib/phusion_passenger/apache2/config_options.rb +104 -0
- data/lib/phusion_passenger/constants.rb +8 -0
- data/lib/phusion_passenger/native_support.rb +9 -1
- data/lib/phusion_passenger/nginx/config_options.rb +328 -0
- data/lib/phusion_passenger/packaging.rb +2 -2
- data/lib/phusion_passenger/platform_info/apache.rb +8 -0
- data/lib/phusion_passenger/platform_info/compiler.rb +2 -2
- data/lib/phusion_passenger/rails3_extensions/init.rb +19 -4
- data/lib/phusion_passenger/ruby_core_enhancements.rb +4 -1
- data/lib/phusion_passenger/standalone/app_finder.rb +3 -2
- data/lib/phusion_passenger/standalone/command.rb +1 -0
- data/lib/phusion_passenger/standalone/runtime_installer.rb +1 -6
- data/lib/phusion_passenger/standalone/runtime_locator.rb +9 -2
- data/lib/phusion_passenger/standalone/start_command.rb +45 -9
- data/lib/phusion_passenger/utils.rb +4 -1
- data/resources/templates/{nginx → installer_common}/run_installer_as_root.txt.erb +3 -1
- data/resources/templates/nginx/nginx_module_sources_not_available.txt.erb +6 -0
- data/resources/templates/standalone/config.erb +8 -8
- data/test/cxx/ApplicationPool2/PoolTest.cpp +120 -3
- data/test/cxx/RequestHandlerTest.cpp +66 -3
- data/test/integration_tests/native_packaging_spec.rb +41 -0
- data/test/integration_tests/nginx_tests.rb +1 -0
- data/test/integration_tests/standalone_tests.rb +4 -0
- data/test/ruby/shared/rails/analytics_logging_extensions_sharedspec.rb +22 -0
- data/test/stub/rails3.0/config/initializers/passenger.rb +2 -1
- data/test/stub/rails3.1/config/initializers/passenger.rb +2 -1
- data/test/stub/rails3.2/config/initializers/passenger.rb +2 -1
- data/test/stub/rails4.0/config/initializers/passenger.rb +5 -1
- data/test/stub/wsgi/passenger_wsgi.py +5 -0
- metadata +32 -7
- metadata.gz.asc +7 -7
- data/resources/templates/apache2/run_installer_as_root.txt.erb +0 -8
data/ext/nginx/config
CHANGED
@@ -34,6 +34,10 @@ NGX_ADDON_SRCS="$NGX_ADDON_SRCS \
|
|
34
34
|
${ngx_addon_dir}/StaticContentHandler.c"
|
35
35
|
NGX_ADDON_DEPS="$NGX_ADDON_DEPS \
|
36
36
|
${ngx_addon_dir}/Configuration.h \
|
37
|
+
${ngx_addon_dir}/ConfigurationCommands.c \
|
38
|
+
${ngx_addon_dir}/CreateLocationConfig.c \
|
39
|
+
${ngx_addon_dir}/MergeLocationConfig.c \
|
40
|
+
${ngx_addon_dir}/CacheLocationConfig.c \
|
37
41
|
${ngx_addon_dir}/ContentHandler.h \
|
38
42
|
${ngx_addon_dir}/StaticContentHandler.h \
|
39
43
|
${ngx_addon_dir}/ngx_http_passenger_module.h \
|
@@ -2,7 +2,7 @@
|
|
2
2
|
* OXT - OS eXtensions for boosT
|
3
3
|
* Provides important functionality necessary for writing robust server software.
|
4
4
|
*
|
5
|
-
* Copyright (c) 2010 Phusion
|
5
|
+
* Copyright (c) 2010-2013 Phusion
|
6
6
|
*
|
7
7
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
* of this software and associated documentation files (the "Software"), to deal
|
@@ -33,6 +33,26 @@ namespace oxt {
|
|
33
33
|
|
34
34
|
class tracable_exception: public std::exception {
|
35
35
|
public:
|
36
|
+
struct no_backtrace { };
|
37
|
+
|
38
|
+
tracable_exception()
|
39
|
+
: std::exception()
|
40
|
+
{
|
41
|
+
// Do nothing.
|
42
|
+
}
|
43
|
+
|
44
|
+
tracable_exception(const tracable_exception &other)
|
45
|
+
: std::exception(other)
|
46
|
+
{
|
47
|
+
// Do nothing.
|
48
|
+
}
|
49
|
+
|
50
|
+
tracable_exception(const no_backtrace &tag)
|
51
|
+
: std::exception()
|
52
|
+
{
|
53
|
+
// Do nothing.
|
54
|
+
}
|
55
|
+
|
36
56
|
virtual std::string backtrace() const throw() {
|
37
57
|
return " (backtrace support disabled during compile time)\n";
|
38
58
|
}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
* OXT - OS eXtensions for boosT
|
3
3
|
* Provides important functionality necessary for writing robust server software.
|
4
4
|
*
|
5
|
-
* Copyright (c) 2010 Phusion
|
5
|
+
* Copyright (c) 2010-2013 Phusion
|
6
6
|
*
|
7
7
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
* of this software and associated documentation files (the "Software"), to deal
|
@@ -37,8 +37,11 @@ class tracable_exception: public std::exception {
|
|
37
37
|
private:
|
38
38
|
std::vector<trace_point *> backtrace_copy;
|
39
39
|
public:
|
40
|
+
struct no_backtrace { };
|
41
|
+
|
40
42
|
tracable_exception();
|
41
43
|
tracable_exception(const tracable_exception &other);
|
44
|
+
tracable_exception(const no_backtrace &tag);
|
42
45
|
virtual ~tracable_exception() throw();
|
43
46
|
virtual std::string backtrace() const throw();
|
44
47
|
virtual const char *what() const throw();
|
data/ext/oxt/implementation.cpp
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* OXT - OS eXtensions for boosT
|
3
3
|
* Provides important functionality necessary for writing robust server software.
|
4
4
|
*
|
5
|
-
* Copyright (c) 2008-
|
5
|
+
* Copyright (c) 2008-2013 Phusion
|
6
6
|
*
|
7
7
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
* of this software and associated documentation files (the "Software"), to deal
|
@@ -204,6 +204,12 @@ tracable_exception::tracable_exception(const tracable_exception &other)
|
|
204
204
|
}
|
205
205
|
}
|
206
206
|
|
207
|
+
tracable_exception::tracable_exception(const no_backtrace &tag)
|
208
|
+
: std::exception()
|
209
|
+
{
|
210
|
+
// Do nothing.
|
211
|
+
}
|
212
|
+
|
207
213
|
tracable_exception::~tracable_exception() throw() {
|
208
214
|
vector<trace_point *>::iterator it, end = backtrace_copy.end();
|
209
215
|
for (it = backtrace_copy.begin(); it != end; it++) {
|
data/ext/oxt/macros.hpp
CHANGED
@@ -98,13 +98,15 @@
|
|
98
98
|
* On MacOS X, neither gcc nor llvm-gcc support the __thread keyword, but Clang
|
99
99
|
* does. It works on at least clang >= 3.0.
|
100
100
|
*/
|
101
|
-
#
|
102
|
-
#if defined(
|
103
|
-
#
|
104
|
-
|
105
|
-
#
|
106
|
-
#
|
107
|
-
#
|
101
|
+
#ifndef PASSENGER_DISABLE_THREAD_LOCAL_STORAGE
|
102
|
+
#if defined(__APPLE__)
|
103
|
+
#if defined(__clang__) && __clang_major__ >= 3
|
104
|
+
#define OXT_THREAD_LOCAL_KEYWORD_SUPPORTED
|
105
|
+
#endif
|
106
|
+
#elif defined(__GNUC__) && OXT_GCC_VERSION >= 40102
|
107
|
+
#if !defined(__SOLARIS__) && !defined(__OpenBSD__)
|
108
|
+
#define OXT_THREAD_LOCAL_KEYWORD_SUPPORTED
|
109
|
+
#endif
|
108
110
|
#endif
|
109
111
|
#endif
|
110
112
|
|
@@ -1,4 +1,27 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
+
# Copyright (c) 2013 Phusion
|
4
|
+
#
|
5
|
+
# "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
12
|
+
# furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included in
|
15
|
+
# all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
# THE SOFTWARE.
|
24
|
+
|
2
25
|
# Parses output of the glibc backtrace() function and
|
3
26
|
# translates addresses into function names and source
|
4
27
|
# file locations.
|
@@ -1,4 +1,27 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
+
# Copyright (c) 2013 Phusion
|
4
|
+
#
|
5
|
+
# "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
12
|
+
# furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included in
|
15
|
+
# all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
# THE SOFTWARE.
|
24
|
+
|
2
25
|
module PhusionPassenger
|
3
26
|
module App
|
4
27
|
def self.options
|
@@ -1,5 +1,28 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# encoding: utf-8
|
3
|
+
# Phusion Passenger - https://www.phusionpassenger.com/
|
4
|
+
# Copyright (c) 2013 Phusion
|
5
|
+
#
|
6
|
+
# "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
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
|
+
|
3
26
|
GC.copy_on_write_friendly = true if GC.respond_to?(:copy_on_write_friendly=)
|
4
27
|
|
5
28
|
module PhusionPassenger
|
@@ -24,11 +24,6 @@
|
|
24
24
|
|
25
25
|
# This script is called during 'gem install'. Its role is to download
|
26
26
|
# Phusion Passenger binaries.
|
27
|
-
source_root = File.expand_path("../..", File.dirname(__FILE__))
|
28
|
-
$LOAD_PATH.unshift("#{source_root}/lib")
|
29
|
-
require 'phusion_passenger'
|
30
|
-
PhusionPassenger.locate_directories
|
31
|
-
require 'fileutils'
|
32
27
|
|
33
28
|
# Create a dummy Makefile to prevent 'gem install' from borking out.
|
34
29
|
File.open("Makefile", "w") do |f|
|
@@ -38,6 +33,16 @@ File.open("Makefile", "w") do |f|
|
|
38
33
|
f.puts " true"
|
39
34
|
end
|
40
35
|
|
36
|
+
# Don't do anything on Windows. We don't support Windows but exiting now
|
37
|
+
# will at least prevent the gem from being not installable on Windows.
|
38
|
+
exit if RUBY_PLATFORM =~ /mswin/i || RUBY_PLATFORM =~ /win32/i
|
39
|
+
|
40
|
+
source_root = File.expand_path("../..", File.dirname(__FILE__))
|
41
|
+
$LOAD_PATH.unshift("#{source_root}/lib")
|
42
|
+
require 'phusion_passenger'
|
43
|
+
PhusionPassenger.locate_directories
|
44
|
+
require 'fileutils'
|
45
|
+
|
41
46
|
if PhusionPassenger.natively_packaged?
|
42
47
|
puts "Binary downloading is only available when originally packaged. Stopping."
|
43
48
|
exit 0
|
@@ -0,0 +1,127 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: binary
|
3
|
+
# Phusion Passenger - https://www.phusionpassenger.com/
|
4
|
+
# Copyright (c) 2013 Phusion
|
5
|
+
#
|
6
|
+
# "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
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
|
+
require 'socket'
|
27
|
+
|
28
|
+
module PhusionPassenger
|
29
|
+
module App
|
30
|
+
def self.options
|
31
|
+
return @@options
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.exit_code_for_exception(e)
|
35
|
+
if e.is_a?(SystemExit)
|
36
|
+
return e.status
|
37
|
+
else
|
38
|
+
return 1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.handshake_and_read_startup_request
|
43
|
+
STDOUT.sync = true
|
44
|
+
STDERR.sync = true
|
45
|
+
puts "!> I have control 1.0"
|
46
|
+
abort "Invalid initialization header" if STDIN.readline != "You have control 1.0\n"
|
47
|
+
|
48
|
+
@@options = {}
|
49
|
+
while (line = STDIN.readline) != "\n"
|
50
|
+
name, value = line.strip.split(/: */, 2)
|
51
|
+
@@options[name] = value
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.ping_port(port)
|
56
|
+
socket_domain = Socket::Constants::AF_INET
|
57
|
+
sockaddr = Socket.pack_sockaddr_in(port, '127.0.0.1')
|
58
|
+
begin
|
59
|
+
socket = Socket.new(socket_domain, Socket::Constants::SOCK_STREAM, 0)
|
60
|
+
begin
|
61
|
+
socket.connect_nonblock(sockaddr)
|
62
|
+
rescue Errno::ENOENT, Errno::EINPROGRESS, Errno::EAGAIN, Errno::EWOULDBLOCK
|
63
|
+
if select(nil, [socket], nil, 0.1)
|
64
|
+
begin
|
65
|
+
socket.connect_nonblock(sockaddr)
|
66
|
+
rescue Errno::EISCONN
|
67
|
+
end
|
68
|
+
else
|
69
|
+
raise Errno::ECONNREFUSED
|
70
|
+
end
|
71
|
+
end
|
72
|
+
return true
|
73
|
+
rescue Errno::ECONNREFUSED, Errno::ENOENT
|
74
|
+
return false
|
75
|
+
ensure
|
76
|
+
socket.close if socket
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def self.load_app
|
81
|
+
port = nil
|
82
|
+
tries = 0
|
83
|
+
while port.nil? && tries < 200
|
84
|
+
port = 1024 + rand(9999)
|
85
|
+
if ping_port(port) || ping_port(port + 1) || ping_port(port + 2)
|
86
|
+
port = nil
|
87
|
+
tries += 1
|
88
|
+
end
|
89
|
+
end
|
90
|
+
if port.nil?
|
91
|
+
abort "Cannot find a suitable port to start Meteor on"
|
92
|
+
end
|
93
|
+
|
94
|
+
production = options["environment"] == "production" ? "production" : ""
|
95
|
+
pid = fork do
|
96
|
+
Process.setpgrp
|
97
|
+
exec("meteor run -p #{port} #{production}")
|
98
|
+
end
|
99
|
+
$0 = options["process_title"] if options["process_title"]
|
100
|
+
$0 = "#{$0} (#{pid})"
|
101
|
+
return [pid, port]
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
################## Main code ##################
|
106
|
+
|
107
|
+
|
108
|
+
handshake_and_read_startup_request
|
109
|
+
pid, port = load_app
|
110
|
+
begin
|
111
|
+
while !ping_port(port)
|
112
|
+
sleep 0.01
|
113
|
+
end
|
114
|
+
puts "!> Ready"
|
115
|
+
puts "!> socket: main;tcp://127.0.0.1:#{port};http_session;0"
|
116
|
+
puts "!> "
|
117
|
+
begin
|
118
|
+
STDIN.readline
|
119
|
+
rescue EOFError
|
120
|
+
end
|
121
|
+
ensure
|
122
|
+
Process.kill('INT', -pid) rescue nil
|
123
|
+
Process.waitpid(pid) rescue nil
|
124
|
+
end
|
125
|
+
|
126
|
+
end # module App
|
127
|
+
end # module PhusionPassenger
|
@@ -1,5 +1,28 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# encoding: binary
|
3
|
+
# Phusion Passenger - https://www.phusionpassenger.com/
|
4
|
+
# Copyright (c) 2013 Phusion
|
5
|
+
#
|
6
|
+
# "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
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
|
+
|
3
26
|
GC.copy_on_write_friendly = true if GC.respond_to?(:copy_on_write_friendly=)
|
4
27
|
|
5
28
|
module PhusionPassenger
|
@@ -1,4 +1,26 @@
|
|
1
1
|
#!/usr/bin/env python
|
2
|
+
# Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
+
# Copyright (c) 2013 Phusion
|
4
|
+
#
|
5
|
+
# "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
12
|
+
# furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included in
|
15
|
+
# all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
# THE SOFTWARE.
|
2
24
|
import sys
|
3
25
|
|
4
26
|
if sys.version_info[0] >= 3:
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
# Phusion Passenger - https://www.phusionpassenger.com/
|
3
|
+
# Copyright (c) 2013 Phusion
|
4
|
+
#
|
5
|
+
# "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
12
|
+
# furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included in
|
15
|
+
# all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
# THE SOFTWARE.
|
24
|
+
|
25
|
+
# This script touches everything in a directory every 30 minutes to prevent
|
26
|
+
# /tmp cleaners from removing it.
|
27
|
+
|
28
|
+
set -e
|
29
|
+
|
30
|
+
dir="$1"
|
31
|
+
while true; do
|
32
|
+
# Sleep for approx 1800 seconds, quit if directory no longer exists.
|
33
|
+
i=0
|
34
|
+
while test $i -lt 900; do
|
35
|
+
sleep 2
|
36
|
+
if ! test -e "$dir"; then
|
37
|
+
exit
|
38
|
+
fi
|
39
|
+
i=$((i+1))
|
40
|
+
done
|
41
|
+
|
42
|
+
# Touch directory, then try loop again.
|
43
|
+
if test -e "$dir"; then
|
44
|
+
find "$dir" | xargs touch
|
45
|
+
else
|
46
|
+
exit
|
47
|
+
fi
|
48
|
+
done
|