Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Watchdog now forces all agents' process groups to exit using SIGKILL,…

… to ensure no garbage processes are left behind.
  • Loading branch information...
commit d9532417680a17dc9fc111b7acd4712de813cb15 1 parent 016e327
@FooBarWidget FooBarWidget authored
View
1  NEWS
@@ -14,6 +14,7 @@ Release 3.9.0
* [Standalone] Automatic asset pipeline expiry headers support.
* [Enterprise] Multithreading support for apps
* Deleting restart.txt will no longer trigger a restart.
+ * The watchdog now forces all agents' process groups to exit using SIGKILL, to ensure no garbage processes are left behind.
Release 3.0.17
View
5 ext/common/agents/HelperAgent/Main.cpp
@@ -446,6 +446,7 @@ class Server {
* instance directory will be cleaned up, making this helper agent
* inaccessible.
*/
+ P_DEBUG("Watchdog seems to be killed; forcing shutdown of all subprocesses");
syscalls::killpg(getpgrp(), SIGKILL);
_exit(2); // In case killpg() fails.
} else {
@@ -486,11 +487,11 @@ main(int argc, char *argv[]) {
UPDATE_TRACE_POINT();
server.mainLoop();
} catch (const tracable_exception &e) {
- P_ERROR(e.what() << "\n" << e.backtrace());
+ P_ERROR("*** ERROR: " << e.what() << "\n" << e.backtrace());
return 1;
}
MultiLibeio::shutdown();
- P_TRACE(2, "Helper agent exited.");
+ P_TRACE(2, "Helper agent exiting with code 0.");
return 0;
}
View
1  ext/common/agents/LoggingAgent/Main.cpp
@@ -283,6 +283,7 @@ main(int argc, char *argv[]) {
P_DEBUG("Logging agent online, listening at " << socketAddress);
ev_run(eventLoop, 0);
+ P_DEBUG("Logging agent exiting with code " << exitCode << ".");
return exitCode;
} catch (const tracable_exception &e) {
P_ERROR("*** ERROR: " << e.what() << "\n" << e.backtrace());
View
13 ext/common/agents/Watchdog/Main.cpp
@@ -1,6 +1,6 @@
/*
* Phusion Passenger - http://www.modrails.com/
- * Copyright (c) 2010 Phusion
+ * Copyright (c) 2010-2012 Phusion
*
* "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
*
@@ -982,12 +982,12 @@ cleanupAgentsInBackground(vector<AgentWatcher *> &watchers) {
// processes.
P_WARN("Some Phusion Passenger agent processes did not exit " <<
"in time, forcefully shutting down all.");
- for (it = watchers.begin(); it != watchers.end(); it++) {
- (*it)->forceShutdown();
- }
} else {
- P_DEBUG("All Phusion Passenger agent processes have exited.");
+ P_DEBUG("All Phusion Passenger agent processes have exited. Forcing all subprocesses to shut down.");
}
+ for (it = watchers.begin(); it != watchers.end(); it++) {
+ (*it)->forceShutdown();
+ }
// Now clean up the server instance directory.
delete generation.get();
@@ -1126,10 +1126,11 @@ main(int argc, char *argv[]) {
* the background and exit this watchdog process so that we don't block
* the web server.
*/
+ P_DEBUG("Web server exited gracefully; gracefully shutting down all agents...");
cleanupAgentsInBackground(watchers);
return 0;
} else {
- P_DEBUG("Web server did not exit gracefully, forcing shutdown of all service processes...");
+ P_DEBUG("Web server did not exit gracefully, forcing shutdown of all agents...");
forceAllAgentsShutdown(watchers);
return 1;
}
View
13 ext/ruby/passenger_native_support.c
@@ -458,6 +458,18 @@ detach_process(VALUE self, VALUE pid) {
return Qnil;
}
+/**
+ * Freeze the current process forever. On Ruby 1.9 this never unlocks the GIL.
+ * Useful for testing purposes.
+ */
+static VALUE
+freeze_process(VALUE self) {
+ while (1) {
+ usleep(60 * 1000000);
+ }
+ return Qnil;
+}
+
#if defined(HAVE_KQUEUE) || defined(IN_DOXYGEN)
typedef struct {
VALUE klass;
@@ -852,6 +864,7 @@ Init_passenger_native_support() {
rb_define_singleton_method(mNativeSupport, "writev3", f_writev3, 4);
rb_define_singleton_method(mNativeSupport, "process_times", process_times, 0);
rb_define_singleton_method(mNativeSupport, "detach_process", detach_process, 1);
+ rb_define_singleton_method(mNativeSupport, "freeze_process", freeze_process, 0);
#ifdef HAVE_KQUEUE
cFileSystemWatcher = rb_define_class_under(mNativeSupport,
Please sign in to comment.
Something went wrong with that request. Please try again.