Changeset 604

Show
Ignore:
Timestamp:
01/13/07 20:25:56 (2 years ago)
Author:
alo
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cherokee-admin/cherokee-admin.py

    r579 r604  
    2222from page_unknown import PageUnknown 
    2323 
    24 DEFAULT_CONFIG_FILE   = "/tmp/cherokee.conf" 
     24 
    2525DEFAULT_CHECKING_TIME = .5 
    26 MODIFIED_EXIT_CODE    = 100 
    2726MODIFIED_CHECK_ELAPSE = 1 
     27 
     28# Paths 
     29# 
     30DEFAULT_CONFIG_FILE   = "/etc/cherokee/cherokee.conf" 
     31NEW_CONFIG_FILE       = "cherokee.conf.brand_new" 
     32 
     33# Exit codes 
     34# 
     35EXIT_IO_ERROR         = 50 
     36EXIT_MODIFIED         = 100 
     37 
     38# Global error flag 
     39# 
     40system_error = None 
     41 
     42 
     43# Check configuration file 
     44# 
     45def check_configuration_file (fullpath): 
     46    global system_error 
     47 
     48    if not os.path.exists (fullpath): 
     49        try: 
     50            s = open (NEW_CONFIG_FILE, 'r') 
     51            content = s.read() 
     52            s.close() 
     53        except IOError: 
     54            system_error = "Couldn't read " + NEW_CONFIG_FILE 
     55            return system_error 
     56 
     57        try: 
     58            t = open (fullpath, 'w+') 
     59            t.write (content) 
     60            t.close() 
     61        except IOError: 
     62            system_error = "Couldn't create " + fullpath 
     63            return system_error 
     64 
    2865 
    2966# Globals 
    3067# 
    3168theme  = Theme() 
    32 config = cherokeeconf.Config(DEFAULT_CONFIG_FILE) 
    33 server = cherokeeconf.Server(config) 
     69 
     70check_configuration_file (DEFAULT_CONFIG_FILE) 
     71 
     72if not system_error: 
     73    config = cherokeeconf.Config(DEFAULT_CONFIG_FILE) 
     74    server = cherokeeconf.Server(config) 
    3475 
    3576 
     
    72113        self.output.write('Content-Type: text/html\r\n\r\n') 
    73114 
     115        # System error 
     116        # 
     117        if system_error: 
     118            self.critical_error (system_error) 
     119            return 
     120         
     121        # Check the URL 
     122        # 
    74123        uri = self.env['REQUEST_URI'] 
    75124        if not uri: 
    76             self._critical_error ('No REQUEST_URI') 
     125            self.critical_error ('No REQUEST_URI') 
    77126            return 
    78127 
     
    121170        if development and scripts_changed (mlist): 
    122171            srv.socket.close() 
    123             sys.exit (MODIFIED_EXIT_CODE
     172            sys.exit (EXIT_MODIFIED
    124173             
    125174        srv.handle_request() 
  • cherokee-admin/page_summary.py

    r572 r604  
    3838        except: 
    3939            html = HTML_NOT_ALIVE 
    40  
     40            pid  = "" 
     41             
    4142        html = html.replace ('%%pid%%', str(pid)) 
    4243        return html 
  • cherokee-admin/server.sh

    r575 r604  
    4141    python cherokee-admin.py $@ 
    4242    if [ "$?" -ne 100 ]; then 
    43            echo "WARNING: Unknown exit error! $?" 
     43           echo "ERROR: Unknown exit error! $?" 
     44           exit $? 
    4445    fi 
    4546    echo "Server restarted: `date`"