This function will handle our server creation, as well as waiting for the server to come online after we've created it.
5619
function handleServerResponse(err, server) {
  if (err) {
    console.dir(err);
    return;
  }

  console.log('SERVER CREATED: ' + server.name + ', waiting for active status');

  // Wait for status: ACTIVE on our server, and then callback
  server.setWait({ status: server.STATUS.running }, 5000, function (err) {
    if (err) {
      console.dir(err);
      return;
    }

    console.log('SERVER INFO');
    console.log(server.name);
    console.log(server.status);
    console.log(server.id);

    console.log('Make sure you DELETE server: ' + server.id +
      ' in order to not accrue billing charges');
  });
}
1243681
function startServer() {
    http.createServer((req, res) => {
        const fileName = __dirname + path.sep + new Date().getTime() + '.png';

        req.on('end', () => {
            res.writeHead(200);
            res.end();

            fs.stat(fileName, function(error, stat) {
              console.log(
                'Stored file ' + fileName +
                ' with size ' + stat.size +
                ', headers: ' + JSON.stringify(req.headers)
              );
              fs.unlinkSync(fileName);
            });
        });
        req.pipe(fs.createWriteStream(fileName));
    }).listen(DEF_CLIENT_PORT);

    console.log("Client server running on port 8124");
}
308167
public function serve()
    {
        $request = Request::createFromGlobals();
        $response = $this->handleRequest($request);

        if ($this->liveReload) $this->injectLiveReload($response);

        $response->send();
    }
907113
function main(args) {
  process.on("uncaughtException", onUncaughtException)

  var opts  = getOpts.parse(args).opts

  var webServer = http.createServer(onRequest)

  utils.log("version: " + utils.VERSION)
  utils.log("server starting")
  webServer.listen(opts.port, function() {
    utils.log("server started on http://localhost:" + opts.port)
  })

  var config = {
    httpServer: webServer
  }

  var rserver = ragentsServer.createServer(config)
  rserver.start()
}
628813
function startServerCmd(options) {
    var deferred = Q.defer()
    var config

    try {
        options = loadOptions(options)
        config = buildConfigFromOptions(options)
        buildServer(config).then(onServerBuilt, onServerBuildFailed)
    } catch(error) {
        deferred.reject(error)
    }

    return deferred.promise


    function onServerBuilt(server) {
        server.start().then(deferred.resolve, onServerStartFailed)
    }

    function onServerBuildFailed(error) {
        var msg = (error && error.message) || 'of no good reason'
        console.error('failed to build server because ' + msg)
        deferred.reject(error)
    }

    function onServerStartFailed(error) {
        var msg = (error && error.message) || 'of no good reason'
        console.error('failed to start server becaue ' + msg)
        deferred.reject(error)
    }
}
388713
public synchronized void waitForStart()
	throws ServerException,
	       ClientException,
	       IOException {
	    try {
	        while(!isStarted() && !hasError()) {
		        wait();
	        }
	    } catch(InterruptedException e) {
            // break
	    }
	    checkError();
    }
66700
def start(self):
        
        Server().start(self.options,self.handler_function, self.__class__.component_type)
685575
def __wait_and_restart():
    
    log.info('Restarting server')
    sleep(1)
    # We can use the default event loop here because this
    # is actually running in a thread. We use aiohttp here because urllib is
    # painful and we don’t have `requests`.
    loop = asyncio.new_event_loop()
    loop.run_until_complete(_resin_supervisor_restart())
1060928
public function start()
    {
        // Create server instance
        $this->serverInstance = $this->createSwooleServerInstance();

        // Bind server events
        $this->bindSwooleServerEvents($this->serverInstance);

        // Start
        $this->serverInstance->start();
    }
1101193
public function onReady()
    {

        // Adding listener
        // ComplexJob - STATE_WAITING
        $job = new \PHPDaemon\Core\ComplexJob(function ($job) {
            // ComplexJob - STATE_DONE
            /*array (
              'bar' =>
              array (
                    'job' => 'bar',
                    'success' => false,
                    'line' => 63,
              ),
              'foo' =>
              array (
                    'job' => 'foo',
                    'success' => true,
                    'line' => 84,
                    'arg' =>
                    array (
                      'param' => 'value',
                    ),
              ),
              'baz' =>
              array (
                    'job' => 'baz',
                    'success' => false,
                    'line' => 94,
              ),
            )*/
            \PHPDaemon\Core\Daemon::log($job->results);
        });

        // Adding listener
        // ComplexJob - STATE_WAITING
        $job->addListener(function ($job) {
            // ComplexJob - STATE_DONE
        });

        // Adding async job foo
        $job('foo', $this->foo(['param' => 'value']));

        // Adding with 1 sec delay
        \PHPDaemon\Core\Timer::add(function ($event) use ($job) {

            // Adding async job bar
            $job('bar', function ($jobname, $job) {
                \PHPDaemon\Core\Timer::add(function ($event) use ($jobname, $job) {
                    // Job done
                    $job->setResult($jobname, ['job' => 'bar', 'success' => false, 'line' => __LINE__]);
                    $event->finish();
                }, 1e3 * 50);
            });

            // Adding async job baz. Equal $job('baz', $this->baz());
            $job->addJob('baz', $this->baz());

            // Run jobs. All listeners will be called when the jobs done
            // ComplexJob - STATE_RUNNING
            $job();

            $event->finish();
        }, 1e6 * 1);
    }
888264
function (server, callback) {
            var self = this;

            this.$server = server;
            this._start(function(err) {
                self.$started = true;
                callback(err);
            });
        }
811764
def _start_server(bindaddr, port, hostname, folder):
    """"""
    import asyncio
    from .httpserver import HttpProtocol
    loop = asyncio.get_event_loop()
    coroutine = loop.create_server(lambda: HttpProtocol(hostname, folder),
                                   bindaddr,
                                   port)
    server = loop.run_until_complete(coroutine)

    print('Starting server on {}'.format(server.sockets[0].getsockname()))
    try:
        loop.run_forever()
    except KeyboardInterrupt:
        pass
370521
def on_welcome(self, connection, event):
        
        # Start the pool
        self.__pool.start()

        logging.info("! Connected to server '%s': %s",
                     event.source, event.arguments[0])
        connection.join("#cohorte")
213259
def serve(self):
        """"""
        while self.ready:
            try:
                self.tick()
            except (KeyboardInterrupt, SystemExit):
                raise
            except Exception:
                self.error_log(
                    'Error in HTTPServer.tick', level=logging.ERROR,
                    traceback=True,
                )

            if self.interrupt:
                while self.interrupt is True:
                    # Wait for self.stop() to complete. See _set_interrupt.
                    time.sleep(0.1)
                if self.interrupt:
                    raise self.interrupt
695590
function() {
	/**
	 * The real PhantomJS instance.
	 *
	 * @type {?}
	 * @private
	 */
	this.instance = null;
	/**
	 * The PhantomJS instance is being created.
	 *
	 * @type {!boolean}
	 * @private
	 */
	this.creating = false;
	/**
	 * PhantomJS flags.
	 *
	 * @type {!string}
	 * @private
	 */
	this.flags = '';
	/**
	 * PhantomJS options.
	 *
	 * @type {!Object}
	 * @private
	 */
	this.options = {
		onStdout: function() {},
		onStderr: function() {}
	};
	/**
	 * List of functions waiting to be called after the PhantomJS
	 *   instance is created.
	 *
	 * @type {!Array.<!function(?)>}
	 * @private
	 */
	this.waiting = [];
	this._createInstance();
}
90530
def start():
    '''
    
    '''
    from wsgiref.simple_server import make_server

    # When started outside of salt-api __opts__ will not be injected
    if '__opts__' not in globals():
        globals()['__opts__'] = get_opts()

        if __virtual__() is False:
            raise SystemExit(1)

    mod_opts = __opts__.get(__virtualname__, {})

    # pylint: disable=C0103
    httpd = make_server('localhost', mod_opts['port'], application)

    try:
        httpd.serve_forever()
    except KeyboardInterrupt:
        raise SystemExit(0)
357278
function Server(/* [options], [connectionListener] */) {
    events.EventEmitter.call(this);
    var self = this;

    var options;
    if (typeof arguments[0] === 'function') {
        options = {};
        this.on('connection', arguments[0]);
    } else {
        options = arguments[0] || {};
        if (typeof arguments[1] === 'function') {
            this.on('connection', arguments[1]);
        }
    }

    this._server = net.createServer(options, this._handler.bind(this));
    this._server.on('listening', function () {
        self.emit('listening');
    })
    this._server.on('close', function () {
        self.emit('close');
    })
    this._server.on('error', function (e) {
        self.emit('error', e);
    });
}