<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def start_selenium_server(self):
 """Start the selenium server """


        ip = BROME_CONFIG['grid_runner']['selenium_server_ip']
        port = BROME_CONFIG['grid_runner']['selenium_server_port']

        def is_selenium_server_is_running():
            s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            result = s.connect_ex((ip, port))
            s.close()
            return not result

        if not is_selenium_server_is_running():
            self.info_log('Starting selenium server...')

            command = BROME_CONFIG['grid_runner']['selenium_server_command']\
                .format(
                    **BROME_CONFIG['grid_runner']
                )

            self.info_log('Selenium hub command: %s' % command)

            process = Popen(
                command.split(' '),
                stdout=open(os.path.join(self.runner_dir, "hub.log"), 'a'),
                stderr=open(os.path.join(self.runner_dir, "hub.log"), 'a'),
            )

            self.selenium_pid = process.pid

            self.info_log('Selenium server pid: %s' % self.selenium_pid)
        else:
            self.info_log('Selenium is already running.')

            # Milestone
            with DbSessionContext(BROME_CONFIG['database']['mongo_database_name']) as session:  # noqa
                test_batch = session.query(Testbatch)\
                    .filter(Testbatch.mongo_id == self.test_batch_id).one()  # noqa
                test_batch.add_milestone(
                    'SeleniumServerAlreadyRunning'
                )
                session.save(test_batch, safe=True)

            return True

        for i in range(30):
            self.info_log('Waiting for the selenium server to start...')
            result = is_selenium_server_is_running()

            if result:
                self.info_log('[Done]Selenium server is running.')

                # Milestone
                with DbSessionContext(BROME_CONFIG['database']['mongo_database_name']) as session:  # noqa
                    test_batch = session.query(Testbatch)\
                        .filter(Testbatch.mongo_id == self.test_batch_id).one()  # noqa
                    test_batch.add_milestone(
                        'SeleniumServerStarted'
                    )
                    session.save(test_batch, safe=True)

                return True
            sleep(2)

        raise Exception("Selenium server did not start!")