Changeset 248:232cdf418e68 for uwsgi.c

Show
Ignore:
Timestamp:
03/03/10 14:10:51 (5 months ago)
Author:
roberto@…
Branch:
default
Message:

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

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • uwsgi.c

    r247 r248  
    505505        int blocking_workers = 0; 
    506506 
    507         char *cwd; 
     507        char *cwd = NULL; 
    508508        int ready_to_reload = 0; 
    509509        int ready_to_die = 0; 
     
    520520        int socket_type = 0; 
    521521        socklen_t socket_type_len; 
     522 
     523        fprintf(stderr,"ARGV0 = %s %s\n", argv[0], argv[1]); 
    522524 
    523525        /* anti signal bombing */ 
     
    602604                {"erlang-cookie", required_argument, 0, LONG_ARGS_ERLANG_COOKIE}, 
    603605                {"nagios", no_argument, &nagios, 1}, 
     606                {"binary-path", required_argument, 0, LONG_ARGS_BINARY_PATH}, 
    604607                {0, 0, 0, 0} 
    605608        }; 
     
    614617        uwsgi.rl.rlim_max = 0; 
    615618 
    616         cwd = uwsgi_get_cwd (); 
    617         uwsgi.binary_path = malloc (strlen (argv[0]) + 1); 
    618         if (uwsgi.binary_path == NULL) { 
    619                 perror ("malloc()"); 
    620                 exit (1); 
    621         } 
    622         strcpy (uwsgi.binary_path, argv[0]); 
    623619 
    624620        env_reloads = getenv("UWSGI_RELOADS"); 
     
    671667#endif 
    672668 
     669        if (uwsgi.binary_path == NULL) { 
     670                cwd = uwsgi_get_cwd (); 
     671                uwsgi.binary_path = malloc (strlen (argv[0]) + 1); 
     672                if (uwsgi.binary_path == NULL) { 
     673                        perror ("malloc()"); 
     674                        exit (1); 
     675                } 
     676                strcpy (uwsgi.binary_path, argv[0]); 
     677        } 
     678 
    673679#ifndef UNBIT 
    674680#ifndef ROCK_SOLID 
     
    13091315#endif 
    13101316                                fprintf (stderr, "binary reloading uWSGI...\n"); 
    1311                                 if (chdir (cwd)) { 
    1312                                         perror ("chdir()"); 
    1313                                         exit (1); 
     1317                                if (cwd) { 
     1318                                        if (chdir (cwd)) { 
     1319                                                perror ("chdir()"); 
     1320                                                exit (1); 
     1321                                        } 
    13141322                                } 
    13151323                                /* check fd table (a module can obviosly open some fd on initialization...) */ 
     
    13281336                                } 
    13291337                                fprintf (stderr, "running %s\n", uwsgi.binary_path); 
    1330                                 strcpy (argv[0], uwsgi.binary_path); 
     1338                                argv[0] = uwsgi.binary_path ; 
     1339                                //strcpy (argv[0], uwsgi.binary_path); 
    13311340                                execve (uwsgi.binary_path, argv, environ); 
    13321341                                perror ("execve()"); 
     
    23192328                case LONG_ARGS_UID: 
    23202329                        uwsgi.uid = atoi (optarg); 
     2330                        break; 
     2331                case LONG_ARGS_BINARY_PATH: 
     2332                        uwsgi.binary_path = optarg; 
    23212333                        break; 
    23222334#ifdef UWSGI_ERLANG