new binary-path options, useful for chroot reloads and cherokee wizard

This commit is contained in:
roberto@sirius
2010-03-03 14:10:51 +01:00
parent 757049d9da
commit 5a279bb170
2 changed files with 32 additions and 23 deletions
+24 -12
View File
@@ -504,7 +504,7 @@ int main (int argc, char *argv[], char *envp[]) {
int working_workers = 0;
int blocking_workers = 0;
char *cwd;
char *cwd = NULL;
int ready_to_reload = 0;
int ready_to_die = 0;
@@ -520,6 +520,8 @@ int main (int argc, char *argv[], char *envp[]) {
int socket_type = 0;
socklen_t socket_type_len;
fprintf(stderr,"ARGV0 = %s %s\n", argv[0], argv[1]);
/* anti signal bombing */
signal (SIGHUP, SIG_IGN);
signal (SIGTERM, SIG_IGN);
@@ -601,6 +603,7 @@ int main (int argc, char *argv[], char *envp[]) {
{"erlang", required_argument, 0, LONG_ARGS_ERLANG},
{"erlang-cookie", required_argument, 0, LONG_ARGS_ERLANG_COOKIE},
{"nagios", no_argument, &nagios, 1},
{"binary-path", required_argument, 0, LONG_ARGS_BINARY_PATH},
{0, 0, 0, 0}
};
#endif
@@ -613,13 +616,6 @@ int main (int argc, char *argv[], char *envp[]) {
uwsgi.rl.rlim_cur = 0;
uwsgi.rl.rlim_max = 0;
cwd = uwsgi_get_cwd ();
uwsgi.binary_path = malloc (strlen (argv[0]) + 1);
if (uwsgi.binary_path == NULL) {
perror ("malloc()");
exit (1);
}
strcpy (uwsgi.binary_path, argv[0]);
env_reloads = getenv("UWSGI_RELOADS");
if (env_reloads) {
@@ -670,6 +666,16 @@ int main (int argc, char *argv[], char *envp[]) {
}
#endif
if (uwsgi.binary_path == NULL) {
cwd = uwsgi_get_cwd ();
uwsgi.binary_path = malloc (strlen (argv[0]) + 1);
if (uwsgi.binary_path == NULL) {
perror ("malloc()");
exit (1);
}
strcpy (uwsgi.binary_path, argv[0]);
}
#ifndef UNBIT
#ifndef ROCK_SOLID
if (uwsgi.shared->options[UWSGI_OPTION_CGI_MODE] == 0) {
@@ -1308,9 +1314,11 @@ int main (int argc, char *argv[], char *envp[]) {
}
#endif
fprintf (stderr, "binary reloading uWSGI...\n");
if (chdir (cwd)) {
perror ("chdir()");
exit (1);
if (cwd) {
if (chdir (cwd)) {
perror ("chdir()");
exit (1);
}
}
/* check fd table (a module can obviosly open some fd on initialization...) */
fprintf (stderr, "closing all fds > 2 (_SC_OPEN_MAX = %ld)...\n", sysconf (_SC_OPEN_MAX));
@@ -1327,7 +1335,8 @@ int main (int argc, char *argv[], char *envp[]) {
}
}
fprintf (stderr, "running %s\n", uwsgi.binary_path);
strcpy (argv[0], uwsgi.binary_path);
argv[0] = uwsgi.binary_path ;
//strcpy (argv[0], uwsgi.binary_path);
execve (uwsgi.binary_path, argv, environ);
perror ("execve()");
// never here
@@ -2319,6 +2328,9 @@ void manage_opt(int i, char *optarg) {
case LONG_ARGS_UID:
uwsgi.uid = atoi (optarg);
break;
case LONG_ARGS_BINARY_PATH:
uwsgi.binary_path = optarg;
break;
#ifdef UWSGI_ERLANG
case LONG_ARGS_ERLANG:
uwsgi.erlang_node = optarg;
+8 -11
View File
@@ -100,6 +100,7 @@ PyAPI_FUNC (PyObject *) PyMarshal_ReadObjectFromString (char *, Py_ssize_t);
#define LONG_ARGS_UDP 17010
#define LONG_ARGS_ERLANG 17011
#define LONG_ARGS_ERLANG_COOKIE 17012
#define LONG_ARGS_BINARY_PATH 17013
#define UWSGI_CLEAR_STATUS uwsgi.workers[uwsgi.mywid].status = 0
@@ -255,8 +256,9 @@ struct __attribute__ ((packed)) wsgi_request {
struct uwsgi_server {
char *pyhome;
#ifndef ROCK_SOLID
int has_threads;
int wsgi_cnt;
int default_app;
@@ -266,7 +268,6 @@ struct __attribute__ ((packed)) wsgi_request {
char *chroot;
gid_t gid;
uid_t uid;
#endif
#endif
char *buffer;
@@ -314,17 +315,17 @@ struct __attribute__ ((packed)) wsgi_request {
int vec_size;
char *sharedarea;
#ifndef __OpenBSD__
void *sharedareamutex;
#endif
int sharedareasize;
/* the list of workers */
struct uwsgi_worker *workers;
pid_t mypid;
int mywid;
struct timeval start_tv;
#ifndef UNBIT
int abstract_socket;
int chmod_socket;
@@ -333,19 +334,16 @@ struct __attribute__ ((packed)) wsgi_request {
#ifdef UWSGI_XML
char *xml_config;
#endif
#ifndef ROCK_SOLID
char *python_path[64];
int python_path_cnt;
char *pyargv;
#endif
#endif
#ifndef ROCK_SOLID
char *wsgi_config;
char *paste;
#endif
#ifndef ROCK_SOLID
int single_interpreter;
int py_optimize;
@@ -357,17 +355,16 @@ struct __attribute__ ((packed)) wsgi_request {
PyObject *workers_tuple;
PyThreadState *main_thread;
#endif
struct pollfd poll;
struct uwsgi_shared *shared ;
#ifndef ROCK_SOLID
struct uwsgi_app wsgi_apps[64];
PyObject *py_apps;
#ifdef UWSGI_ERLANG
int erlang_nodes;
int erlangfd;
#endif