Changeset 239:d6735a53d498 for uwsgi.c
Legend:
- Unmodified
- Added
- Removed
-
uwsgi.c
r238 r239 55 55 static const char *app_slash = "/"; 56 56 #endif 57 58 extern char **environ; 57 59 58 60 int find_worker_id (pid_t pid) { … … 532 534 int ready_to_die = 0; 533 535 536 char *env_reloads ; 537 unsigned int reloads = 0; 534 538 int is_a_reload = 0; 539 char env_reload_buf[11]; 535 540 536 541 char *buffer; … … 668 673 strcpy (binary_path, argv[0]); 669 674 675 env_reloads = getenv("UWSGI_RELOADS"); 676 if (env_reloads) { 677 // convert env value to int 678 reloads = atoi(env_reloads); 679 reloads++; 680 // convert reloads to string 681 rlen = snprintf(env_reload_buf, 10, "%u", reloads) ; 682 if (rlen > 0) { 683 env_reload_buf[rlen] = 0 ; 684 if (setenv("UWSGI_RELOADS",env_reload_buf, 1)) { 685 perror("setenv()"); 686 } 687 } 688 } 689 else { 690 fprintf(stderr,"setting UWSGI_RELOADS\n"); 691 if (setenv("UWSGI_RELOADS","0", 1)) { 692 perror("setenv()"); 693 } 694 } 695 670 696 socket_type_len = sizeof (int); 671 697 if (!getsockopt (3, SOL_SOCKET, SO_TYPE, &socket_type, &socket_type_len)) { 672 if (socket_type == SOCK_STREAM ) {698 if (socket_type == SOCK_STREAM && reloads > 0) { 673 699 fprintf (stderr, "...fd 3 is a socket, i suppose this is a graceful reload of uWSGI, i will try to do my best...\n"); 674 700 is_a_reload = 1; … … 1517 1543 fprintf (stderr, "running %s\n", binary_path); 1518 1544 strcpy (argv[0], binary_path); 1519 execve (binary_path, argv, env p);1545 execve (binary_path, argv, environ); 1520 1546 perror ("execve()"); 1521 1547 exit (1);
