def server_handler(args):
    """server_handler."""
    if not db.setup(url=args.db, echo=args.db_echo):
        return
    if not _check_db_revision():
        return

    app = create_app()
    listener = '{:s}:{:d}'.format(args.host, args.port)
    if args.debug:
        logging.getLogger('werkzeug').disabled = True
        set_loglevel(logging.DEBUG)
        app.config['ENV'] = 'development'
        app.debug = True

        _show_banner_debug(app, listener)
        from werkzeug.serving import run_simple
        run_simple(
            args.host, args.port, app, use_reloader=True, use_debugger=True,
            threaded=True)
    else:
        app.config['ENV'] = 'production'
        import gevent
        from gevent.pywsgi import WSGIServer
        http_server = WSGIServer(listener, application=app, log=None)

        def stop_server():
            if http_server.started:
                http_server.stop()

        gevent.signal(signal.SIGTERM, stop_server)
        gevent.signal(signal.SIGINT, stop_server)
        logger.info(' * Environment: {}'.format(app.config['ENV']))
        logger.info(' * Running on http://{}/ (Press CTRL+C to quit)'.format(
            listener))

        try:
            http_server.serve_forever()
        except (KeyboardInterrupt, SystemExit):
            stop_server()