~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to tests/lib/server_mgmt/server_management.py

  • Committer: patrick crews
  • Date: 2011-02-11 23:56:37 UTC
  • mto: This revision was merged to the branch mainline in revision 2164.
  • Revision ID: gleebix@gmail.com-20110211235637-s2nuuhtj0sgebybp
Added in --gdb and --manual-gdb option as well as --drizzled option

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
    def __init__(self, system_manager, variables):
40
40
        self.skip_keys = [ 'ld_lib_paths'
41
41
                         , 'system_manager'
 
42
                         , 'logging'
 
43
                         , 'gdb'
 
44
                         , 'code_tree'
42
45
                         ]
43
46
        self.debug = variables['debug']
44
47
        self.verbose = variables['verbose']
47
50
        self.no_secure_file_priv = variables['nosecurefilepriv']
48
51
        self.system_manager = system_manager
49
52
        self.logging = system_manager.logging
 
53
        self.gdb  = self.system_manager.gdb
50
54
        self.code_tree = system_manager.code_tree
 
55
        self.user_server_opts = variables['drizzledoptions']
51
56
        self.servers = {}
52
57
        # We track this
53
58
        self.ld_lib_paths = system_manager.ld_lib_paths
54
59
        self.mutex = thread.allocate_lock()
55
 
        self.timer_increment = .25
 
60
        self.timer_increment = .5
56
61
 
57
62
        if self.debug:
58
63
            self.logging.debug_class(self)
92
97
            Start up occurs elsewhere
93
98
 
94
99
        """
 
100
 
95
101
        # Get a name for our server
96
102
        server_name = self.get_server_name(requester)
97
103
 
98
 
        # initialize a server_object
 
104
        # initialize our new server_object
99
105
        if self.code_tree.type == 'Drizzle':
100
106
          from lib.server_mgmt.drizzled import drizzleServer as server_type
101
107
        new_server = server_type( server_name, self, server_options
139
145
        # we don't know the server is running (still starting up)
140
146
        # so we give it a few minutes
141
147
        self.tried_start = 1
142
 
        server_subproc = subprocess.Popen( start_cmd
143
 
                                         , shell=True
144
 
                                         , env=working_environ
145
 
                                         )
146
 
        server_subproc.wait()
147
 
        server_retcode = server_subproc.returncode
148
 
        #print server_subproc.pid
 
148
        error_log = open(server.error_log,'w')
 
149
        if start_cmd: # It will be none if --manual-gdb used
 
150
            if not self.gdb:
 
151
                server_subproc = subprocess.Popen( start_cmd
 
152
                                                 , shell=True
 
153
                                                 , env=working_environ
 
154
                                                 , stdout=error_log
 
155
                                                 , stderr=error_log
 
156
                                                 )
 
157
                server_subproc.wait()
 
158
                server_retcode = server_subproc.returncode
 
159
            else: 
 
160
                # This is a bit hackish - need to see if there is a cleaner
 
161
                # way of handling this
 
162
                # It is annoying that we have to say stdout + stderr = None
 
163
                # We might need to further manipulate things so that we 
 
164
                # have a log
 
165
                server_subproc = subprocess.Popen( start_cmd
 
166
                                                 , shell=True
 
167
                                                 , env = working_environ
 
168
                                                 , stdin=None
 
169
                                                 , stdout=None
 
170
                                                 , stderr=None
 
171
                                                 , close_fds=True
 
172
                                                 )
 
173
        
 
174
                server_retcode = 0
 
175
        else:
 
176
            # manual-gdb issue
 
177
            server_retcode = 0
149
178
        timer = float(0)
150
179
        timeout = float(server.server_start_timeout)
 
180
 
151
181
        #if server_retcode: # We know we have an error, no need to wait
152
182
        #    timer = timeout
153
183
 
157
187
        while not self.system_manager.find_path( [server.pid_file]
158
188
                                               , required=0) and timer != timeout:
159
189
            time.sleep(self.timer_increment)
160
 
            timer= timer + self.timer_increment
161
 
 
 
190
            # If manual-gdb, this == None and we want to give the 
 
191
            # user all the time they need
 
192
            if start_cmd:
 
193
                timer= timer + self.timer_increment
 
194
            
162
195
        if timer == timeout and not self.ping_server(server, quiet=True):
163
196
            self.logging.error(( "Server failed to start within %d seconds.  This could be a problem with the test machine or the server itself" %(timeout)))
164
197
            server_retcode = 1
275
308
        current_servers = self.servers[requester]
276
309
        
277
310
        for server in current_servers:
 
311
            # We add in any user-supplied options here
 
312
            server_options = server_options + self.user_server_opts
278
313
            if self.compare_options( server.server_options
279
314
                                   , server_options):
280
315
                return 1