Changeset 247:d5fd9e46d3d3 for uwsgi.c

Show
Ignore:
Timestamp:
03/02/10 17:57:09 (5 months ago)
Author:
roberto@…
Branch:
default
Message:

nagios plugin mode

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • uwsgi.c

    r246 r247  
    175175void internal_server_error (int fd, char *message) { 
    176176#ifndef UNBIT 
    177         if (uwsgi.options[UWSGI_OPTION_CGI_MODE] == 0) { 
     177        if (uwsgi.shared->options[UWSGI_OPTION_CGI_MODE] == 0) { 
    178178#endif 
    179179                wsgi_req.headers_size = write (fd, "HTTP/1.1 500 Internal Server Error\r\nContent-type: text/html\r\n\r\n", 63); 
     
    198198                len = PyString_Size (data); 
    199199#ifndef ROCK_SOLID 
    200                 if (uwsgi.has_threads && uwsgi.options[UWSGI_OPTION_THREADS] == 1) { 
     200                if (uwsgi.has_threads && uwsgi.shared->options[UWSGI_OPTION_THREADS] == 1) { 
    201201                        Py_BEGIN_ALLOW_THREADS wsgi_req.response_size = write (uwsgi.poll.fd, content, len); 
    202202                Py_END_ALLOW_THREADS} 
     
    260260 
    261261#ifndef UNBIT 
    262         if (uwsgi.options[UWSGI_OPTION_CGI_MODE] == 0) { 
     262        if (uwsgi.shared->options[UWSGI_OPTION_CGI_MODE] == 0) { 
    263263                base = 4; 
    264264#endif 
     
    480480        int rlen; 
    481481 
     482#ifdef UWSGI_NAGIOS 
     483        int nagios = 0 ; 
     484#endif 
     485 
    482486#ifdef UWSGI_SCTP 
    483487        int i_am_sctp = 0; 
     
    486490 
    487491        char *udp_socket = NULL; 
    488         struct pollfd udp_poll; 
     492        struct pollfd uwsgi_poll; 
    489493        struct sockaddr_in udp_client; 
    490494        socklen_t udp_len; 
     
    523527        memset (&uwsgi, 0, sizeof (struct uwsgi_server)); 
    524528 
    525         /* shared area for dynamic options */ 
    526         uwsgi.options = (uint32_t *) mmap (NULL, sizeof (uint32_t) * (0xFF + 1), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); 
    527         if (!uwsgi.options) { 
     529        /* generic shared area */ 
     530        uwsgi.shared = (struct uwsgi_shared *) mmap (NULL, sizeof (struct uwsgi_shared), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); 
     531        if (!uwsgi.shared) { 
    528532                perror ("mmap()"); 
    529533                exit (1); 
    530534        } 
    531         memset (uwsgi.options, 0, sizeof (uint32_t) * (0xFF + 1)); 
    532  
    533         /* hooks */ 
    534         uwsgi.hooks = mmap (NULL, sizeof (void *) * (0xFF + 1), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); 
    535         if (!uwsgi.hooks) { 
    536                 perror ("mmap()"); 
    537                 exit (1); 
    538         } 
    539         memset (uwsgi.hooks, 0, sizeof (void *) * (0xFF + 1)); 
    540  
    541         /* hooks */ 
    542         uwsgi.after_hooks = mmap (NULL, sizeof (void *) * (0xFF + 1), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); 
    543         if (!uwsgi.after_hooks) { 
    544                 perror ("mmap()"); 
    545                 exit (1); 
    546         } 
    547         memset (uwsgi.after_hooks, 0, sizeof (void *) * (0xFF + 1)); 
     535        memset (uwsgi.shared, 0, sizeof (struct uwsgi_shared)); 
    548536 
    549537        for(i=0;i<0xFF;i++) { 
    550                 uwsgi.hooks[i] = unconfigured_hook; 
    551                 uwsgi.after_hooks[i] = unconfigured_after_hook; 
     538                uwsgi.shared->hooks[i] = unconfigured_hook; 
     539                uwsgi.shared->after_hooks[i] = unconfigured_after_hook; 
    552540        } 
    553541 
     
    564552        uwsgi.vec_size = 4 + 1 + (4 * MAX_VARS); 
    565553 
    566         uwsgi.options[UWSGI_OPTION_SOCKET_TIMEOUT] = 4; 
    567         uwsgi.options[UWSGI_OPTION_LOGGING] = 1; 
     554        uwsgi.shared->options[UWSGI_OPTION_SOCKET_TIMEOUT] = 4; 
     555        uwsgi.shared->options[UWSGI_OPTION_LOGGING] = 1; 
    568556 
    569557#ifndef UNBIT 
     
    613601                {"erlang", required_argument, 0, LONG_ARGS_ERLANG}, 
    614602                {"erlang-cookie", required_argument, 0, LONG_ARGS_ERLANG_COOKIE}, 
     603                {"nagios", no_argument, &nagios, 1}, 
    615604                {0, 0, 0, 0} 
    616605        }; 
     
    684673#ifndef UNBIT 
    685674#ifndef ROCK_SOLID 
    686         if (uwsgi.options[UWSGI_OPTION_CGI_MODE] == 0) { 
     675        if (uwsgi.shared->options[UWSGI_OPTION_CGI_MODE] == 0) { 
    687676#endif 
    688677#endif 
     
    717706                        } 
    718707#ifdef __linux__ 
    719                         if (uwsgi.options[UWSGI_OPTION_MEMORY_DEBUG]) { 
     708                        if (uwsgi.shared->options[UWSGI_OPTION_MEMORY_DEBUG]) { 
    720709                                fprintf (stderr, "*** Warning, on linux system you have to bind-mount the /proc fs in your chroot to get memory debug/report.\n"); 
    721710                        } 
     
    783772        fprintf (stderr, "your memory page size is %d bytes\n", uwsgi.page_size); 
    784773 
    785 #ifndef UNBIT 
    786         fprintf (stderr, "your server socket listen backlog is limited to %d connections\n", uwsgi.listen_queue); 
    787 #endif 
    788774 
    789775        if (uwsgi.synclog) { 
     
    977963        } 
    978964 
     965#endif 
     966 
     967        if (uwsgi.buffer_size > 65536) { 
     968                fprintf (stderr, "invalid buffer size.\n"); 
     969                exit (1); 
     970        } 
     971        uwsgi.buffer = malloc (uwsgi.buffer_size); 
     972        if (uwsgi.buffer == NULL) { 
     973                fprintf (stderr, "unable to allocate memory for buffer.\n"); 
     974                exit (1); 
     975        } 
     976 
     977        fprintf (stderr, "request/response buffer (%d bytes) allocated.\n", uwsgi.buffer_size); 
     978 
     979#ifdef UWSGI_NAGIOS 
     980        if (nagios) { 
     981                // connect and send 
     982                if (uwsgi.socket_name == NULL) { 
     983                        fprintf(stdout,"UWSGI UNKNOWN: you have specified an invalid socket\n"); 
     984                        exit(3); 
     985                } 
     986                char *tcp_port = strchr (uwsgi.socket_name, ':'); 
     987                if (tcp_port == NULL) { 
     988                        fprintf(stdout,"UWSGI UNKNOWN: you have specified an invalid socket\n"); 
     989                        exit(3); 
     990                } 
     991 
     992                tcp_port[0] = 0 ; 
     993 
     994                uwsgi_poll.fd = connect_to_tcp(uwsgi.socket_name, atoi(tcp_port+1), uwsgi.shared->options[UWSGI_OPTION_SOCKET_TIMEOUT]); 
     995                if (uwsgi_poll.fd < 0) { 
     996                        fprintf(stdout,"UWSGI CRITICAL: could not connect() to workers\n"); 
     997                        exit(2); 
     998                } 
     999                wsgi_req.modifier = UWSGI_MODIFIER_PING ; 
     1000                wsgi_req.size = 0 ; 
     1001                wsgi_req.modifier_arg = 0 ; 
     1002                if (write(uwsgi_poll.fd, &wsgi_req, 4) != 4) { 
     1003                        perror("write()"); 
     1004                        fprintf(stdout,"UWSGI CRITICAL: could not send ping packet to workers\n"); 
     1005                        exit(2); 
     1006                } 
     1007                uwsgi_poll.events = POLLIN ; 
     1008                if (!uwsgi_parse_response (&uwsgi_poll, uwsgi.shared->options[UWSGI_OPTION_SOCKET_TIMEOUT], (struct uwsgi_header *) &wsgi_req, uwsgi.buffer)) { 
     1009                        fprintf(stdout,"UWSGI CRITICAL: timed out waiting for response\n"); 
     1010                        exit(2);         
     1011                } 
     1012                else { 
     1013                        if (wsgi_req.size > 0) { 
     1014                                fprintf(stdout,"UWSGI WARNING: %.*s\n", wsgi_req.size, uwsgi.buffer);  
     1015                                exit(1); 
     1016                        } 
     1017                        else { 
     1018                                fprintf(stdout,"UWSGI OK: armed and ready\n"); 
     1019                                exit(0); 
     1020                        } 
     1021                } 
     1022 
     1023                // never here 
     1024                fprintf(stdout,"UWSGI UNKNOWN: probably you hit a bug of uWSGI !!!\n"); 
     1025                exit(3); 
     1026                 
     1027        } 
    9791028#endif 
    9801029 
     
    10221071 
    10231072 
     1073#ifndef UNBIT 
     1074        fprintf (stderr, "your server socket listen backlog is limited to %d connections\n", uwsgi.listen_queue); 
     1075#endif 
     1076 
    10241077 
    10251078        if (uwsgi.single_interpreter == 1) { 
     
    10611114#endif 
    10621115 
    1063         if (uwsgi.buffer_size > 65536) { 
    1064                 fprintf (stderr, "invalid buffer size.\n"); 
    1065                 exit (1); 
    1066         } 
    1067         uwsgi.buffer = malloc (uwsgi.buffer_size); 
    1068         if (uwsgi.buffer == NULL) { 
    1069                 fprintf (stderr, "unable to allocate memory for buffer.\n"); 
    1070                 exit (1); 
    1071         } 
    1072  
    1073         fprintf (stderr, "request/response buffer (%d bytes) allocated.\n", uwsgi.buffer_size); 
    10741116 
    10751117        /* save the masterpid */ 
     
    10781120        fprintf(stderr,"initializing hooks..."); 
    10791121 
    1080         uwsgi.hooks[0] = uwsgi_request_wsgi ;  
    1081         uwsgi.after_hooks[0] = uwsgi_after_request_wsgi ;  
    1082  
    1083         uwsgi.hooks[UWSGI_MODIFIER_ADMIN_REQUEST] = uwsgi_request_admin ; //10 
     1122        uwsgi.shared->hooks[0] = uwsgi_request_wsgi ;  
     1123        uwsgi.shared->after_hooks[0] = uwsgi_after_request_wsgi ;  
     1124 
     1125        uwsgi.shared->hooks[UWSGI_MODIFIER_ADMIN_REQUEST] = uwsgi_request_admin ; //10 
    10841126#ifdef UWSGI_SPOOLER 
    1085         uwsgi.hooks[UWSGI_MODIFIER_SPOOL_REQUEST] = uwsgi_request_spooler ; //17 
    1086 #endif 
    1087         uwsgi.hooks[UWSGI_MODIFIER_FASTFUNC] = uwsgi_request_fastfunc ; //26 
    1088  
    1089         uwsgi.hooks[UWSGI_MODIFIER_MANAGE_PATH_INFO] = uwsgi_request_wsgi ; // 30 
    1090         uwsgi.after_hooks[UWSGI_MODIFIER_MANAGE_PATH_INFO] = uwsgi_after_request_wsgi; // 30 
    1091  
    1092         uwsgi.hooks[UWSGI_MODIFIER_MESSAGE_MARSHAL] = uwsgi_request_marshal ; //33 
    1093         uwsgi.hooks[UWSGI_MODIFIER_PING] = uwsgi_request_ping ; //100 
     1127        uwsgi.shared->hooks[UWSGI_MODIFIER_SPOOL_REQUEST] = uwsgi_request_spooler ; //17 
     1128#endif 
     1129        uwsgi.shared->hooks[UWSGI_MODIFIER_FASTFUNC] = uwsgi_request_fastfunc ; //26 
     1130 
     1131        uwsgi.shared->hooks[UWSGI_MODIFIER_MANAGE_PATH_INFO] = uwsgi_request_wsgi ; // 30 
     1132        uwsgi.shared->after_hooks[UWSGI_MODIFIER_MANAGE_PATH_INFO] = uwsgi_after_request_wsgi; // 30 
     1133 
     1134        uwsgi.shared->hooks[UWSGI_MODIFIER_MESSAGE_MARSHAL] = uwsgi_request_marshal ; //33 
     1135        uwsgi.shared->hooks[UWSGI_MODIFIER_PING] = uwsgi_request_ping ; //100 
    10941136 
    10951137        fprintf(stderr,"done.\n"); 
     
    11681210#ifdef UWSGI_SPOOLER 
    11691211        if (spool_dir != NULL) { 
    1170                 uwsgi.workers[0].spooler_pid = spooler_start (uwsgi.serverfd, uwsgi_module); 
     1212                uwsgi.shared->spooler_pid = spooler_start (uwsgi.serverfd, uwsgi_module); 
    11711213        } 
    11721214#endif 
     
    12361278 
    12371279                if (udp_socket) { 
    1238                         udp_poll.fd = bind_to_udp (udp_socket); 
    1239                         if (udp_poll.fd < 0) { 
     1280                        uwsgi_poll.fd = bind_to_udp (udp_socket); 
     1281                        if (uwsgi_poll.fd < 0) { 
    12401282                                fprintf (stderr, "unable to bind to udp socket. SNMP and cluster management services will be disabled.\n"); 
    12411283                        } 
    12421284                        else { 
    12431285                                fprintf (stderr, "UDP server enabled.\n"); 
    1244                                 udp_poll.events = POLLIN; 
     1286                                uwsgi_poll.events = POLLIN; 
    12451287                        } 
    12461288                } 
     
    12481290                        if (ready_to_die >= uwsgi.numproc && uwsgi.to_hell) { 
    12491291#ifdef UWSGI_SPOOLER 
    1250                                 if (spool_dir && uwsgi.workers[0].spooler_pid > 0) { 
    1251                                         kill (uwsgi.workers[0].spooler_pid, SIGKILL); 
    1252                                         fprintf(stderr,"killed the spooler with pid %d\n", uwsgi.workers[0].spooler_pid); 
     1292                                if (spool_dir && uwsgi.shared->spooler_pid > 0) { 
     1293                                        kill (uwsgi.shared->spooler_pid, SIGKILL); 
     1294                                        fprintf(stderr,"killed the spooler with pid %d\n", uwsgi.shared->spooler_pid); 
    12531295                                } 
    12541296 
     
    12591301                        if (ready_to_reload >= uwsgi.numproc && uwsgi.to_heaven) { 
    12601302#ifdef UWSGI_SPOOLER 
    1261                                 if (spool_dir && uwsgi.workers[0].spooler_pid > 0) { 
    1262                                         kill (uwsgi.workers[0].spooler_pid, SIGKILL); 
    1263                                         fprintf(stderr,"wait4() the spooler with pid %d...", uwsgi.workers[0].spooler_pid); 
    1264                                         diedpid = waitpid(uwsgi.workers[0].spooler_pid, &waitpid_status, 0); 
     1303                                if (spool_dir && uwsgi.shared->spooler_pid > 0) { 
     1304                                        kill (uwsgi.shared->spooler_pid, SIGKILL); 
     1305                                        fprintf(stderr,"wait4() the spooler with pid %d...", uwsgi.shared->spooler_pid); 
     1306                                        diedpid = waitpid(uwsgi.shared->spooler_pid, &waitpid_status, 0); 
    12651307                                        fprintf(stderr,"done."); 
    12661308                                } 
     
    13051347                                 */ 
    13061348#ifdef UWSGI_THREADING 
    1307                                 if (uwsgi.has_threads && uwsgi.options[UWSGI_OPTION_THREADS] == 1) { 
     1349                                if (uwsgi.has_threads && uwsgi.shared->options[UWSGI_OPTION_THREADS] == 1) { 
    13081350                                        uwsgi._save = PyEval_SaveThread (); 
    13091351                                        uwsgi.workers[uwsgi.mywid].i_have_gil = 0; 
     
    13111353#endif 
    13121354                                /* all processes ok, doing status scan after N seconds */ 
    1313                                 check_interval.tv_sec = uwsgi.options[UWSGI_OPTION_MASTER_INTERVAL]; 
     1355                                check_interval.tv_sec = uwsgi.shared->options[UWSGI_OPTION_MASTER_INTERVAL]; 
    13141356                                if (!check_interval.tv_sec) 
    13151357                                        check_interval.tv_sec = 1; 
    13161358                                 
    1317                                 if (udp_socket && udp_poll.fd >= 0) { 
    1318                                         rlen = poll (&udp_poll, 1, check_interval.tv_sec * 1000); 
     1359                                if (udp_socket && uwsgi_poll.fd >= 0) { 
     1360                                        rlen = poll (&uwsgi_poll, 1, check_interval.tv_sec * 1000); 
    13191361                                        if (rlen < 0) { 
    13201362                                                perror ("poll()"); 
     
    13221364                                        else if (rlen > 0) { 
    13231365                                                udp_len = sizeof (udp_client); 
    1324                                                 rlen = recvfrom (udp_poll.fd, uwsgi.buffer, uwsgi.buffer_size, 0, (struct sockaddr *) &udp_client, &udp_len); 
     1366                                                rlen = recvfrom (uwsgi_poll.fd, uwsgi.buffer, uwsgi.buffer_size, 0, (struct sockaddr *) &udp_client, &udp_len); 
    13251367                                                if (rlen < 0) { 
    13261368                                                        perror ("recvfrom()"); 
     
    13311373                                                                fprintf (stderr, "received udp packet of %d bytes from %s:%d\n", rlen, udp_client_addr, ntohs (udp_client.sin_port)); 
    13321374                                                                if (uwsgi.buffer[0] == 0x30) { 
    1333                                                                         manage_snmp (udp_poll.fd, (uint8_t *) uwsgi.buffer, rlen, &udp_client); 
     1375                                                                        manage_snmp (uwsgi_poll.fd, (uint8_t *) uwsgi.buffer, rlen, &udp_client); 
    13341376                                                                } 
    13351377                                                        } 
     
    13511393                                } 
    13521394#endif 
    1353                                 check_interval.tv_sec = uwsgi.options[UWSGI_OPTION_MASTER_INTERVAL]; 
     1395                                check_interval.tv_sec = uwsgi.shared->options[UWSGI_OPTION_MASTER_INTERVAL]; 
    13541396                                if (!check_interval.tv_sec) 
    13551397                                        check_interval.tv_sec = 1; 
     
    13791421#ifdef UWSGI_SPOOLER 
    13801422                        /* reload the spooler */ 
    1381                         if (spool_dir && uwsgi.workers[0].spooler_pid > 0) { 
    1382                                 if (diedpid == uwsgi.workers[0].spooler_pid) { 
     1423                        if (spool_dir && uwsgi.shared->spooler_pid > 0) { 
     1424                                if (diedpid == uwsgi.shared->spooler_pid) { 
    13831425                                        fprintf(stderr,"OOOPS the spooler is no more...trying respawn...\n"); 
    1384                                         uwsgi.workers[0].spooler_pid = spooler_start (uwsgi.serverfd, uwsgi_module); 
     1426                                        uwsgi.shared->spooler_pid = spooler_start (uwsgi.serverfd, uwsgi_module); 
    13851427                                        continue; 
    13861428                                } 
     
    14281470                                fprintf (stderr, "Respawned uWSGI worker (new pid: %d)\n", pid); 
    14291471#ifdef UWSGI_SPOOLER 
    1430                                 if (uwsgi.mywid <= 0 && diedpid != uwsgi.workers[0].spooler_pid) { 
     1472                                if (uwsgi.mywid <= 0 && diedpid != uwsgi.shared->spooler_pid) { 
    14311473#else 
    14321474                                if (uwsgi.mywid <= 0) { 
     
    14471489        } 
    14481490 
    1449         if (uwsgi.options[UWSGI_OPTION_HARAKIRI] > 0 && !uwsgi.master_process) { 
     1491        if (uwsgi.shared->options[UWSGI_OPTION_HARAKIRI] > 0 && !uwsgi.master_process) { 
    14501492                signal (SIGALRM, (void *) &harakiri); 
    14511493        } 
     
    15111553                UWSGI_SET_IN_REQUEST; 
    15121554 
    1513                 if (uwsgi.options[UWSGI_OPTION_LOGGING]) 
     1555                if (uwsgi.shared->options[UWSGI_OPTION_LOGGING]) 
    15141556                        gettimeofday (&wsgi_req.start_of_request, NULL); 
    15151557 
     
    15411583                else { 
    15421584#endif 
    1543                         if (!uwsgi_parse_response (&uwsgi.poll, uwsgi.options[UWSGI_OPTION_SOCKET_TIMEOUT], (struct uwsgi_header *) &wsgi_req, uwsgi.buffer)) { 
     1585                        if (!uwsgi_parse_response (&uwsgi.poll, uwsgi.shared->options[UWSGI_OPTION_SOCKET_TIMEOUT], (struct uwsgi_header *) &wsgi_req, uwsgi.buffer)) { 
    15441586                                continue; 
    15451587                        } 
     
    15491591 
    15501592                // enter harakiri mode 
    1551                 if (uwsgi.options[UWSGI_OPTION_HARAKIRI] > 0) { 
    1552                         set_harakiri(uwsgi.options[UWSGI_OPTION_HARAKIRI]); 
    1553                 } 
    1554  
    1555                 ret = (*uwsgi.hooks[wsgi_req.modifier])(&uwsgi, &wsgi_req); 
     1593                if (uwsgi.shared->options[UWSGI_OPTION_HARAKIRI] > 0) { 
     1594                        set_harakiri(uwsgi.shared->options[UWSGI_OPTION_HARAKIRI]); 
     1595                } 
     1596 
     1597                ret = (*uwsgi.shared->hooks[wsgi_req.modifier])(&uwsgi, &wsgi_req); 
    15561598                // calculate execution time 
    15571599                gettimeofday(&wsgi_req.end_of_request, NULL) ; 
     
    15601602 
    15611603                // get memory usage 
    1562                 if (uwsgi.options[UWSGI_OPTION_MEMORY_DEBUG] == 1) 
     1604                if (uwsgi.shared->options[UWSGI_OPTION_MEMORY_DEBUG] == 1) 
    15631605                        get_memusage(); 
    15641606 
     
    15691611 
    15701612                if (!ret) 
    1571                         (*uwsgi.after_hooks[wsgi_req.modifier])(&uwsgi, &wsgi_req); 
     1613                        (*uwsgi.shared->after_hooks[wsgi_req.modifier])(&uwsgi, &wsgi_req); 
    15721614 
    15731615 
     
    15791621 
    15801622                // defunct process reaper 
    1581                 if (uwsgi.options[UWSGI_OPTION_REAPER] == 1) { 
     1623                if (uwsgi.shared->options[UWSGI_OPTION_REAPER] == 1) { 
    15821624                        waitpid (-1, &waitpid_status, WNOHANG); 
    15831625                } 
     
    15901632#endif 
    15911633 
    1592                 if (uwsgi.options[UWSGI_OPTION_MAX_REQUESTS] > 0 && uwsgi.workers[uwsgi.mywid].requests >= uwsgi.options[UWSGI_OPTION_MAX_REQUESTS]) { 
     1634                if (uwsgi.shared->options[UWSGI_OPTION_MAX_REQUESTS] > 0 && uwsgi.workers[uwsgi.mywid].requests >= uwsgi.shared->options[UWSGI_OPTION_MAX_REQUESTS]) { 
    15931635                        goodbye_cruel_world (); 
    15941636                } 
     
    23052347                        break; 
    23062348                case LONG_ARGS_CHECK_INTERVAL: 
    2307                         uwsgi.options[UWSGI_OPTION_MASTER_INTERVAL] = atoi (optarg); 
     2349                        uwsgi.shared->options[UWSGI_OPTION_MASTER_INTERVAL] = atoi (optarg); 
    23082350                        break; 
    23092351                case LONG_ARGS_PYARGV: 
     
    23212363                        break; 
    23222364                case 'L': 
    2323                         uwsgi.options[UWSGI_OPTION_LOGGING] = 0; 
     2365                        uwsgi.shared->options[UWSGI_OPTION_LOGGING] = 0; 
    23242366                        break; 
    23252367#ifdef UWSGI_SPOOLER 
     
    23822424                        break; 
    23832425                case 'r': 
    2384                         uwsgi.options[UWSGI_OPTION_REAPER] = 1; 
     2426                        uwsgi.shared->options[UWSGI_OPTION_REAPER] = 1; 
    23852427                        break; 
    23862428#ifndef ROCK_SOLID 
     
    23902432                        break; 
    23912433                case 'm': 
    2392                         uwsgi.options[UWSGI_OPTION_MEMORY_DEBUG] = 1; 
     2434                        uwsgi.shared->options[UWSGI_OPTION_MEMORY_DEBUG] = 1; 
    23932435                        break; 
    23942436                case 'O': 
     
    23972439#endif 
    23982440                case 't': 
    2399                         uwsgi.options[UWSGI_OPTION_HARAKIRI] = atoi (optarg); 
     2441                        uwsgi.shared->options[UWSGI_OPTION_HARAKIRI] = atoi (optarg); 
    24002442                        break; 
    24012443                case 'b': 
     
    24052447#ifndef ROCK_SOLID 
    24062448                case 'c': 
    2407                         uwsgi.options[UWSGI_OPTION_CGI_MODE] = 1; 
     2449                        uwsgi.shared->options[UWSGI_OPTION_CGI_MODE] = 1; 
    24082450                        break; 
    24092451#endif 
     
    24192461                        break; 
    24202462                case 'R': 
    2421                         uwsgi.options[UWSGI_OPTION_MAX_REQUESTS] = atoi (optarg); 
     2463                        uwsgi.shared->options[UWSGI_OPTION_MAX_REQUESTS] = atoi (optarg); 
    24222464                        break; 
    24232465                case 'z': 
    24242466                        if (atoi (optarg) > 0) { 
    2425                                 uwsgi.options[UWSGI_OPTION_SOCKET_TIMEOUT] = atoi (optarg); 
     2467                                uwsgi.shared->options[UWSGI_OPTION_SOCKET_TIMEOUT] = atoi (optarg); 
    24262468                        } 
    24272469                        break; 
     
    24292471                case 'T': 
    24302472                        uwsgi.has_threads = 1; 
    2431                         uwsgi.options[UWSGI_OPTION_THREADS] = 1; 
     2473                        uwsgi.shared->options[UWSGI_OPTION_THREADS] = 1; 
    24322474                        break; 
    24332475                case 'P':