GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Description: Phusion Passenger (mod_rails)
Homepage: http://www.modrails.com/
Clone URL: git://github.com/FooBarWidget/passenger.git
Click here to lend your support to: passenger and make a donation at www.pledgie.com !
Add a new config option: PassengerMaxRequests. This allows one to specify 
how many requests an application instance may process. The option doesn't 
do anything yet.
Hongli Lai (Phusion) (author)
Sat Aug 02 08:34:27 -0700 2008
commit  dacb6bea76278011f9f6c0d1873a46d2b6a9d2ca
tree    50205a36439090615bf87ed1e276e697fbf40e38
parent  1d7875aa1774eb679fa6a52afa8069fc116b6e68
...
68
69
70
 
 
71
72
73
...
97
98
99
 
100
101
102
...
277
278
279
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280
281
282
...
462
463
464
465
 
 
 
 
 
 
466
467
468
...
494
495
496
497
 
498
499
500
501
502
 
503
504
505
...
68
69
70
71
72
73
74
75
...
99
100
101
102
103
104
105
...
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
...
483
484
485
 
486
487
488
489
490
491
492
493
494
...
520
521
522
 
523
524
525
526
527
 
528
529
530
531
0
@@ -68,6 +68,8 @@ passenger_config_create_dir(apr_pool_t *p, char *dirspec) {
0
   config->spawnMethod = DirConfig::SM_UNSET;
0
   config->frameworkSpawnerTimeout = -1;
0
   config->appSpawnerTimeout = -1;
0
+ config->maxRequests = 0;
0
+ config->maxRequestsSpecified = false;
0
   return config;
0
 }
0
 
0
@@ -97,6 +99,7 @@ passenger_config_merge_dir(apr_pool_t *p, void *basev, void *addv) {
0
   config->spawnMethod = (add->spawnMethod == DirConfig::SM_UNSET) ? base->spawnMethod : add->spawnMethod;
0
   config->frameworkSpawnerTimeout = (add->frameworkSpawnerTimeout == -1) ? base->frameworkSpawnerTimeout : add->frameworkSpawnerTimeout;
0
   config->appSpawnerTimeout = (add->appSpawnerTimeout == -1) ? base->appSpawnerTimeout : add->appSpawnerTimeout;
0
+ config->maxRequests = (!add->maxRequestsSpecified) ? base->maxRequests : add->maxRequests;
0
   return config;
0
 }
0
 
0
@@ -277,6 +280,24 @@ cmd_passenger_default_user(cmd_parms *cmd, void *dummy, const char *arg) {
0
 }
0
 
0
 static const char *
0
+cmd_passenger_max_requests(cmd_parms *cmd, void *pcfg, const char *arg) {
0
+ DirConfig *config = (DirConfig *) pcfg;
0
+ char *end;
0
+ long int result;
0
+
0
+ result = strtol(arg, &end, 10);
0
+ if (*end != '\0') {
0
+ return "Invalid number specified for PassengerMaxRequests.";
0
+ } else if (result < 0) {
0
+ return "Value for PassengerMaxRequests must be greater than or equal to 0.";
0
+ } else {
0
+ config->maxRequests = (unsigned long) result;
0
+ config->maxRequestsSpecified = true;
0
+ return NULL;
0
+ }
0
+}
0
+
0
+static const char *
0
 cmd_passenger_disable(cmd_parms *cmd, void *pcfg) {
0
   DirConfig *config = (DirConfig *) pcfg;
0
   config->enabled = DirConfig::DISABLED;
0
@@ -462,7 +483,12 @@ const command_rec passenger_commands[] = {
0
     NULL,
0
     RSRC_CONF,
0
     "The user that Rails/Rack applications must run as when user switching fails or is disabled."),
0
- AP_INIT_NO_ARGS("PassengerDisable",
0
+ AP_INIT_TAKE1("PassengerMaxRequests", // TODO: document this
0
+ (Take1Func) cmd_passenger_max_requests,
0
+ NULL,
0
+ OR_LIMIT,
0
+ "The user that Rails/Rack applications must run as when user switching fails or is disabled."),
0
+ AP_INIT_NO_ARGS("PassengerDisable", // TODO: document this
0
     (Take0Func) cmd_passenger_disable,
0
     NULL,
0
     OR_ALL,
0
@@ -494,12 +520,12 @@ const command_rec passenger_commands[] = {
0
     NULL,
0
     RSRC_CONF,
0
     "The spawn method to use."),
0
- AP_INIT_TAKE1("RailsFrameworkSpawnerIdleTime",
0
+ AP_INIT_TAKE1("RailsFrameworkSpawnerIdleTime", // TODO: document this
0
     (Take1Func) cmd_rails_framework_spawner_idle_time,
0
     NULL,
0
     RSRC_CONF,
0
     "The maximum number of seconds that an application spawner may be idle before it is shutdown."),
0
- AP_INIT_TAKE1("RailsAppSpawnerIdleTime",
0
+ AP_INIT_TAKE1("RailsAppSpawnerIdleTime", // TODO: document this
0
     (Take1Func) cmd_rails_app_spawner_idle_time,
0
     NULL,
0
     RSRC_CONF,
...
93
94
95
 
 
 
 
 
 
 
 
 
 
96
97
98
...
116
117
118
 
 
 
 
 
 
 
 
119
120
121
...
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
...
126
127
128
129
130
131
132
133
134
135
136
137
138
139
0
@@ -93,6 +93,16 @@
0
        */
0
       long appSpawnerTimeout;
0
       
0
+ /**
0
+ * The maximum number of requests that the spawned application may process
0
+ * before exiting. A value of 0 means unlimited.
0
+ */
0
+ unsigned long maxRequests;
0
+
0
+ /** Indicates whether the maxRequests option was explicitly specified
0
+ * in the directory configuration. */
0
+ bool maxRequestsSpecified;
0
+
0
       const char *getRailsEnv() const {
0
         if (railsEnv != NULL) {
0
           return railsEnv;
0
@@ -116,6 +126,14 @@
0
           return "smart";
0
         }
0
       }
0
+
0
+ unsigned long getMaxRequests() {
0
+ if (maxRequestsSpecified) {
0
+ return maxRequests;
0
+ } else {
0
+ return 0;
0
+ }
0
+ }
0
     };
0
     
0
     /**
...
682
683
684
685
686
687
688
...
694
695
696
697
 
 
698
699
700
...
682
683
684
 
685
686
687
...
693
694
695
 
696
697
698
699
700
0
@@ -682,7 +682,6 @@ public:
0
       
0
       UPDATE_TRACE_POINT();
0
       try {
0
- const char*environment, *spawnMethod;
0
         ServerConfig *sconfig;
0
         
0
         sconfig = getServerConfig(r->server);
0
@@ -694,7 +693,8 @@ public:
0
           config->getSpawnMethodString(),
0
           mapper.getApplicationTypeString(),
0
           config->appSpawnerTimeout,
0
- config->frameworkSpawnerTimeout));
0
+ config->frameworkSpawnerTimeout,
0
+ config->getMaxRequests()));
0
         P_TRACE(3, "Forwarding " << r->uri << " to PID " << session->getPid());
0
       } catch (const SpawnException &e) {
0
         if (e.hasErrorPage()) {

Comments

    No one has commented yet.