コード例 #1
0
ファイル: server.py プロジェクト: AppleDevelopment/mineos
    def check_interval(self):
        from procfs_reader import path_owner
        from time import sleep

        crons = []
        
        for action in ('backup','archive'):
            for server in mc.list_servers_to_act(action, self.base_directory):
                crons.append( (action, server) )

        for action, server in crons:
            try:
                path_ = os.path.join(self.base_directory, mc.DEFAULT_PATHS['servers'], server)
                getattr(mc(server, path_owner(path_), self.base_directory), 'commit')()
            except Exception:
                pass
        else:
            sleep(len(crons) * mc.COMMIT_DELAY)

        for action, server in crons:
            try:
                path_ = os.path.join(self.base_directory, mc.DEFAULT_PATHS['servers'], server)
                getattr(mc(server, path_owner(path_), self.base_directory), action)()
                sleep(mc.COMMIT_DELAY)
            except Exception:
                pass
コード例 #2
0
ファイル: server.py プロジェクト: jmorgensen/mineos
 def check_interval(self):
     from procfs_reader import path_owner
     
     for action in ('backup','archive'):
         for i in mc.list_servers_to_act(action, self.base_directory):
             path_ = os.path.join(self.base_directory, mc.DEFAULT_PATHS['servers'], i)
             getattr(mc(i, path_owner(path_), self.base_directory), action)()
コード例 #3
0
    def check_interval(self):
        from procfs_reader import path_owner

        for action in ('backup', 'archive'):
            for i in mc.list_servers_to_act(action, self.base_directory):
                path_ = os.path.join(self.base_directory,
                                     mc.DEFAULT_PATHS['servers'], i)
                getattr(mc(i, path_owner(path_), self.base_directory),
                        action)()
コード例 #4
0
             print ex.message
 elif args.cmd == 'stop':
     from procfs_reader import path_owner
     for i in mc.list_servers_up():
         if os.path.samefile(i.base_dir, args.base_directory):
             try:
                 srv_ = i.server_name
                 owner = path_owner(os.path.join(i.base_dir, mc.DEFAULT_PATHS['servers'], srv_))
                 print "sending '%s' to %s..." % (args.cmd, srv_),
                 instance = mc(srv_, owner, i.base_dir)._command_stuff(args.cmd)
                 print ' done'
             except Exception as ex:
                 print ex.message               
 elif args.cmd in ['backup', 'archive']:
     from procfs_reader import path_owner
     for i in mc.list_servers_to_act(args.cmd, args.base_directory):
         try:
             owner = path_owner(os.path.join(args.base_directory, mc.DEFAULT_PATHS['servers'], i))
             print 'starting %s for %s...' % (args.cmd, i),
             getattr(mc, args.cmd)(i, owner, args.base_directory)
             print ' done'
         except Exception as ex:
             print ex.message
 elif args.cmd == 'restore':
     from procfs_reader import path_owner
     for i in mc.list_servers_restore_at_boot(args.base_directory):
         try:
             owner = path_owner(os.path.join(args.base_directory, mc.DEFAULT_PATHS['backup'], i))
             print 'starting %s for %s...' % (args.cmd, i),
             mc(i, owner, args.base_directory).restore()
             print ' done'
コード例 #5
0
ファイル: mineos_console.py プロジェクト: Robitobi01/MineOS3
             print(ex)
 elif args.cmd == 'stop':
     for i in mc.list_servers_up():
         try:
             srv_ = i.server_name
             owner = path_owner(
                 os.path.join(args.base_directory,
                              mc.DEFAULT_PATHS['servers'], srv_))
             print("sending '%s' to %s..." % (args.cmd, srv_), end=' ')
             instance = mc(srv_, owner,
                           args.base_directory)._command_stuff(args.cmd)
             print(' done')
         except Exception as ex:
             print(ex)
 elif args.cmd in ['backup', 'archive']:
     for i in mc.list_servers_to_act(args.cmd, args.base_directory):
         try:
             owner = path_owner(
                 os.path.join(args.base_directory,
                              mc.DEFAULT_PATHS['servers'], i))
             print('starting %s for %s...' % (args.cmd, i), end=' ')
             getattr(mc, args.cmd)(i, owner, args.base_directory)
             print(' done')
         except Exception as ex:
             print(ex)
 elif args.cmd == 'restore':
     for i in mc.list_servers_restore_at_boot(args.base_directory):
         try:
             owner = path_owner(
                 os.path.join(args.base_directory,
                              mc.DEFAULT_PATHS['backup'], i))
コード例 #6
0
    def check_interval(self):
        from procfs_reader import path_owner
        from time import sleep
        from subprocess import CalledProcessError

        crons = []

        for action in ('restart', 'backup', 'archive'):
            for server in mc.list_servers_to_act(action, self.base_directory):
                crons.append((action, server))

        for action in ('backups_keep', 'archives_keep'):
            for server in mc.list_servers_to_prune(action,
                                                   self.base_directory):
                crons.append((action, server))

        for server in set(s for a, s in crons):
            path_ = os.path.join(self.base_directory,
                                 mc.DEFAULT_PATHS['servers'], server)
            instance = mc(server, path_owner(path_), self.base_directory)

            cherrypy.log('[%s] commit' % server)
            try:
                instance._command_stuff('save-off')
                instance.commit()
            except RuntimeError:
                pass
            else:
                cherrypy.log(
                    '[%s] commit command received by process; sleeping %ssec' %
                    (server, self.commit_delay))
                sleep(self.commit_delay)

        for action, server in crons:
            path_ = os.path.join(self.base_directory,
                                 mc.DEFAULT_PATHS['servers'], server)
            instance = mc(server, path_owner(path_), self.base_directory)

            if action == 'restart':
                cherrypy.log('[%s] stop' % server)
                try:
                    instance._command_stuff('stop')
                except RuntimeError:
                    pass
                else:
                    cherrypy.log(
                        '[%s] stop command received by process; sleeping %ssec'
                        % (server, self.commit_delay))
                    sleep(self.commit_delay)
            elif action in ('backup', 'archive'):
                cherrypy.log('[%s] %s (Server Up: %s)' %
                             (server, action, instance.up))
                try:
                    getattr(instance, action)()
                except CalledProcessError as e:
                    cherrypy.log('[%s] %s exception: returncode %s' %
                                 (server, action, e.returncode))
                    cherrypy.log(e.output)
                except RuntimeError:
                    cherrypy.log(
                        '[%s] %s exception: server state changed since beginning of %s.'
                        % (server, action, action))
                    cherrypy.log('[%s] %s (Server Up: %s)' %
                                 (server, action, instance.up))
                    cherrypy.log(
                        'You may need to increase mineos.conf => server.commit_delay'
                    )
                else:
                    cherrypy.log(
                        '[%s] %s return code reports success; sleeping 3sec' %
                        (server, action))
                    sleep(3)
            elif action in ('backups_keep', 'archives_keep'):
                param = instance.server_config.getint('crontabs', action)
                cherrypy.log('[%s] %s %s (Server Up: %s)' %
                             (server, action, param, instance.up))
                try:
                    getattr(instance, action)(param)
                except CalledProcessError as e:
                    cherrypy.log('[%s] %s exception: returncode %s' %
                                 (server, action, e.returncode))
                    cherrypy.log(e.output)
                except RuntimeError:
                    cherrypy.log(
                        '[%s] %s exception: server state changed since beginning of %s.'
                        % (server, action, action))
                    cherrypy.log('[%s] %s (Server Up: %s)' %
                                 (server, action, instance.up))
                    cherrypy.log(
                        'You may need to increase mineos.conf => server.commit_delay'
                    )
                else:
                    cherrypy.log(
                        '[%s] %s return code reports success; sleeping 3sec' %
                        (server, action))
                    sleep(3)

        for action, server in crons:
            path_ = os.path.join(self.base_directory,
                                 mc.DEFAULT_PATHS['servers'], server)
            instance = mc(server, path_owner(path_), self.base_directory)

            if action == 'restart':
                if instance.up:
                    cherrypy.log('[%s] extra delay; sleeping %s seconds' %
                                 (server, self.commit_delay))
                    sleep(self.commit_delay)

                cherrypy.log('[%s] start' % server)
                try:
                    instance.start()
                except RuntimeError:
                    pass
                else:
                    cherrypy.log('[%s] started; sleeping %s seconds' %
                                 (server, self.commit_delay))
                    sleep(self.commit_delay)
コード例 #7
0
    def check_interval(self):
        from procfs_reader import path_owner
        from time import sleep
        from subprocess import CalledProcessError
        
        crons = []
        
        for action in ('restart','backup','archive'):
            for server in mc.list_servers_to_act(action, self.base_directory):
                crons.append( (action, server) )

        for server in set(s for a,s in crons):
            path_ = os.path.join(self.base_directory, mc.DEFAULT_PATHS['servers'], server)
            instance = mc(server, path_owner(path_), self.base_directory)

            cherrypy.log('[%s] commit' % server)
            try:
                instance._command_stuff('save-off')
                instance.commit()
            except RuntimeError:
                pass
            else:
                sleep(self.commit_delay)

        for action, server in crons:
            path_ = os.path.join(self.base_directory, mc.DEFAULT_PATHS['servers'], server)
            instance = mc(server, path_owner(path_), self.base_directory)

            if action == 'restart':
                cherrypy.log('[%s] stop' % server)
                try:
                    instance._command_stuff('stop')
                except RuntimeError:
                    pass
                else:
                    sleep(self.commit_delay)
            elif action in ('backup', 'archive'):
                cherrypy.log('[%s] %s' % (server, action))
                try:
                    getattr(instance, action)()
                except CalledProcessError as e:
                    cherrypy.log('[%s] %s exception: returncode %s' % (server, action, e.returncode))
                    cherrypy.log(e.output)
                else:
                    sleep(self.commit_delay)
                
        for action, server in crons:
            path_ = os.path.join(self.base_directory, mc.DEFAULT_PATHS['servers'], server)
            instance = mc(server, path_owner(path_), self.base_directory)
            
            if action == 'restart':
                if instance.up:
                    cherrypy.log('[%s] extra delay' % server)
                    sleep(self.commit_delay)

                cherrypy.log('[%s] start' % server)
                try:
                    instance.start()
                except RuntimeError:
                    pass
                else:
                    sleep(self.commit_delay)
コード例 #8
0
ファイル: server.py プロジェクト: MiLk/mineos
    def check_interval(self):
        from procfs_reader import path_owner
        from time import sleep
        from subprocess import CalledProcessError
        
        crons = []
        
        for action in ('restart','backup','archive'):
            for server in mc.list_servers_to_act(action, self.base_directory):
                crons.append( (action, server) )

        for server in set(s for a,s in crons):
            path_ = os.path.join(self.base_directory, mc.DEFAULT_PATHS['servers'], server)
            instance = mc(server, path_owner(path_), self.base_directory)

            cherrypy.log('[%s] commit' % server)
            try:
                instance._command_stuff('save-off')
                instance.commit()
            except RuntimeError:
                pass
            else:
                cherrypy.log('[%s] commit command received by process; sleeping %ssec' % (server, self.commit_delay))
                sleep(self.commit_delay)

        for action, server in crons:
            path_ = os.path.join(self.base_directory, mc.DEFAULT_PATHS['servers'], server)
            instance = mc(server, path_owner(path_), self.base_directory)

            if action == 'restart':
                cherrypy.log('[%s] stop' % server)
                try:
                    instance._command_stuff('stop')
                except RuntimeError:
                    pass
                else:
                    cherrypy.log('[%s] stop command received by process; sleeping %ssec' % (server, self.commit_delay))
                    sleep(self.commit_delay)
            elif action in ('backup', 'archive'):
                cherrypy.log('[%s] %s (Server Up: %s)' % (server, action, instance.up))
                try:
                    getattr(instance, action)()
                except CalledProcessError as e:
                    cherrypy.log('[%s] %s exception: returncode %s' % (server, action, e.returncode))
                    cherrypy.log(e.output)
                except RuntimeError:
                    cherrypy.log('[%s] %s exception: server state changed since beginning of %s.' % (server, action, action))
                    cherrypy.log('[%s] %s (Server Up: %s)' % (server, action, instance.up))
                    cherrypy.log('You may need to increase mineos.conf => server.commit_delay')
                else:
                    cherrypy.log('[%s] %s return code reports success; sleeping 3sec' % (server, action))
                    sleep(3)
                
        for action, server in crons:
            path_ = os.path.join(self.base_directory, mc.DEFAULT_PATHS['servers'], server)
            instance = mc(server, path_owner(path_), self.base_directory)
            
            if action == 'restart':
                if instance.up:
                    cherrypy.log('[%s] extra delay; sleeping %s seconds' % (server, self.commit_delay))
                    sleep(self.commit_delay)

                cherrypy.log('[%s] start' % server)
                try:
                    instance.start()
                except RuntimeError:
                    pass
                else:
                    cherrypy.log('[%s] started; sleeping %s seconds' % (server, self.commit_delay))
                    sleep(self.commit_delay)
コード例 #9
0
ファイル: server.py プロジェクト: bryanchriswhite/mineos
    def check_interval(self):
        from procfs_reader import path_owner
        from time import sleep
        from subprocess import CalledProcessError
        
        crons = []
        
        for action in ('restart','backup','archive'):
            for server in mc.list_servers_to_act(action, self.base_directory):
                crons.append( (action, server) )

        for server in set(s for a,s in crons):
            path_ = os.path.join(self.base_directory, mc.DEFAULT_PATHS['servers'], server)
            instance = mc(server, path_owner(path_), self.base_directory)

            cherrypy.log('[%s] commit' % server)
            try:
                instance._command_stuff('save-off')
                instance.commit()
            except RuntimeError:
                pass
            else:
                sleep(self.commit_delay)

        for action, server in crons:
            path_ = os.path.join(self.base_directory, mc.DEFAULT_PATHS['servers'], server)
            instance = mc(server, path_owner(path_), self.base_directory)

            if action == 'restart':
                cherrypy.log('[%s] stop' % server)
                try:
                    instance._command_stuff('stop')
                except RuntimeError:
                    pass
                else:
                    sleep(self.commit_delay)
            elif action in ('backup', 'archive'):
                cherrypy.log('[%s] %s' % (server, action))
                try:
                    getattr(instance, action)()
                except CalledProcessError as e:
                    cherrypy.log('[%s] %s exception: returncode %s' % (server, action, e.returncode))
                    cherrypy.log(e.output)
                else:
                    sleep(self.commit_delay)
                
        for action, server in crons:
            path_ = os.path.join(self.base_directory, mc.DEFAULT_PATHS['servers'], server)
            instance = mc(server, path_owner(path_), self.base_directory)
            
            if action == 'restart':
                if instance.up:
                    cherrypy.log('[%s] extra delay' % server)
                    sleep(self.commit_delay)

                cherrypy.log('[%s] start' % server)
                try:
                    instance.start()
                except RuntimeError:
                    pass
                else:
                    sleep(self.commit_delay)