Initialize the raven client and fatal error handler (shutdown function)
192591
public function initializeObject()
    {
        $client = new \Raven_Client($this->dsn);
        $errorHandler = new \Raven_ErrorHandler($client, true);
        $errorHandler->registerShutdownFunction();
        $this->client = $client;

        $this->setTags();
        $this->setEnvironment();
        $this->setRelease();
        $this->setAppPath();
        $this->setPrefixes();

        $this->emitSentryClientCreated($client);
    }
573145
private synchronized void init(MasterInquireClient masterInquireClient) {
    mMasterInquireClient = masterInquireClient;
    mFileSystemMasterClientPool =
        new FileSystemMasterClientPool(mClientContext, mMasterInquireClient);
    mBlockMasterClientPool = new BlockMasterClientPool(mClientContext, mMasterInquireClient);
    mClosed.set(false);

    if (mClientContext.getConf().getBoolean(PropertyKey.USER_METRICS_COLLECTION_ENABLED)) {
      // setup metrics master client sync
      mMetricsMasterClient = new MetricsMasterClient(MasterClientContext
          .newBuilder(mClientContext)
          .setMasterInquireClient(mMasterInquireClient)
          .build());
      mClientMasterSync = new ClientMasterSync(mMetricsMasterClient, mAppId);
      mExecutorService = Executors.newFixedThreadPool(1,
          ThreadFactoryUtils.build("metrics-master-heartbeat-%d", true));
      mExecutorService
          .submit(new HeartbeatThread(HeartbeatContext.MASTER_METRICS_SYNC, mClientMasterSync,
              (int) mClientContext.getConf().getMs(PropertyKey.USER_METRICS_HEARTBEAT_INTERVAL_MS),
              mClientContext.getConf()));
      // register the shutdown hook
      try {
        Runtime.getRuntime().addShutdownHook(new MetricsMasterSyncShutDownHook());
      } catch (IllegalStateException e) {
        // this exception is thrown when the system is already in the process of shutting down. In
        // such a situation, we are about to shutdown anyway and there is no need to register this
        // shutdown hook
      } catch (SecurityException e) {
        LOG.info("Not registering metrics shutdown hook due to security exception. Regular "
            + "heartbeats will still be performed to collect metrics data, but no final heartbeat "
            + "will be performed on JVM exit. Security exception: {}", e.toString());
      }
    }
  }
864615
public void invoke() throws InternalException, CloudException {

        final ClientAndResponse clientAndResponse = invokeInternal();
        clientAndResponse.client.getConnectionManager().shutdown();
    }
1060064
@Override
  public void onShutdownRequest() {
    this.reefEventHandlers.onRuntimeStatus(RuntimeStatusEventImpl.newBuilder()
        .setName(RUNTIME_NAME).setState(State.DONE).build());
    this.driverStatusManager.onError(new Exception("Shutdown requested by YARN."));
  }
14886
function start(callback) {
  let handle = {close(){server.close()}}
  check(function _check(err, inUse) {
    if (err) throw err
    if (inUse) {
      server = {close(){}}
      init(callback)
    }
    else {
      server = dynalite({
        createTableMs: 0
      }).listen(5000, function _server(err) {
        if (err) {
          // if we err then the db has been started elsewhere..
          // just try to continue
          console.log(err)
        }
        init(callback)
      })
    }
  })
  return handle
}
1093805
def init(*args, **kwargs):
    
    global _initial_client
    client = Client(*args, **kwargs)
    Hub.current.bind_client(client)
    rv = _InitGuard(client)
    if client is not None:
        _initial_client = weakref.ref(client)
    return rv
595632
def initiate_shutdown(self):
        
        # Windows does not provide SIGKILL, go with SIGTERM then.
        sig = getattr(signal, "SIGKILL", signal.SIGTERM)
        # reloader active
        if is_running_from_reloader():
            os.kill(os.getpid(), sig)
        # python 2.7
        self.server._BaseServer__shutdown_request = True
        # python 2.6
        self.server._BaseServer__serving = False
1222406
public function shutdownFunction() {
		if(($e=error_get_last()) && $e !== static::$errorAtStart) {
			foreach($this->ignoreDirs as $dir) {
				if(strpos($e['file'], $dir) === 0)
					return;
			}

			while(ob_get_level()) ob_end_clean();
			$exceptionHandler = set_exception_handler(function() {});
			restore_exception_handler();
			$exception = new FatalErrorException($e['message'], $e['type'], 0, $e['file'], $e['line']);
			call_user_func_array($exceptionHandler, [$exception]);
		}
	}
182157
def instantiate_client(_unused_client, _unused_to_delete):
    """"""

    # [START client_create_default]
    from google.cloud import logging

    client = logging.Client()
    # [END client_create_default]

    credentials = object()
    # [START client_create_explicit]
    from google.cloud import logging

    client = logging.Client(project="my-project", credentials=credentials)
894620
function(dsn, options) {
    var self = this;

    if (self._globalServer) {
      this._logDebug('error', 'Error: Raven has already been configured');
      return self;
    }
    if (!dsn) return self;

    var globalOptions = self._globalOptions;

    // merge in options
    if (options) {
      each(options, function(key, value) {
        // tags and extra are special and need to be put into context
        if (key === 'tags' || key === 'extra' || key === 'user') {
          self._globalContext[key] = value;
        } else {
          globalOptions[key] = value;
        }
      });
    }

    self.setDSN(dsn);

    // "Script error." is hard coded into browsers for errors that it can't read.
    // this is the result of a script being pulled in from an external domain and CORS.
    globalOptions.ignoreErrors.push(/^Script error\.?$/);
    globalOptions.ignoreErrors.push(/^Javascript error: Script error\.? on line 0$/);

    // join regexp rules into one big rule
    globalOptions.ignoreErrors = joinRegExp(globalOptions.ignoreErrors);
    globalOptions.ignoreUrls = globalOptions.ignoreUrls.length
      ? joinRegExp(globalOptions.ignoreUrls)
      : false;
    globalOptions.whitelistUrls = globalOptions.whitelistUrls.length
      ? joinRegExp(globalOptions.whitelistUrls)
      : false;
    globalOptions.includePaths = joinRegExp(globalOptions.includePaths);
    globalOptions.maxBreadcrumbs = Math.max(
      0,
      Math.min(globalOptions.maxBreadcrumbs || 100, 100)
    ); // default and hard limit is 100

    var autoBreadcrumbDefaults = {
      xhr: true,
      console: true,
      dom: true,
      location: true,
      sentry: true
    };

    var autoBreadcrumbs = globalOptions.autoBreadcrumbs;
    if ({}.toString.call(autoBreadcrumbs) === '[object Object]') {
      autoBreadcrumbs = objectMerge(autoBreadcrumbDefaults, autoBreadcrumbs);
    } else if (autoBreadcrumbs !== false) {
      autoBreadcrumbs = autoBreadcrumbDefaults;
    }
    globalOptions.autoBreadcrumbs = autoBreadcrumbs;

    var instrumentDefaults = {
      tryCatch: true
    };

    var instrument = globalOptions.instrument;
    if ({}.toString.call(instrument) === '[object Object]') {
      instrument = objectMerge(instrumentDefaults, instrument);
    } else if (instrument !== false) {
      instrument = instrumentDefaults;
    }
    globalOptions.instrument = instrument;

    TraceKit.collectWindowErrors = !!globalOptions.collectWindowErrors;

    // return for chaining
    return self;
  }
1314098
function initApi(opts) {
	var logMarker = require.emitter.id + ':' + process.pid
	log = function () {
		console.log(logMarker, util.format.apply(this, Array.prototype.slice.call(arguments)))
	}
	var logger

	if (Array.isArray(opts.ignoredSignals)) 	opts.ignoredSignals.forEach(function (signal) {
		process.on(signal, getSignalHandler(signal))
	})


	if (process.send) {
		logger = new rotatedlogger.RotatedLog({stdout: false, file: true, streamOpts: {logFile: opts.logName}})

		process.stdin.setEncoding('utf-8') // returns undefined
		process.stdin.on('data', stdinDataListener) // returns this
			.once('close', stdinCloseListener)
			.resume()
		process.send('ok') // let parent know we are ready
	} else {
		log('Fatal: ipc not available')
		shutdown()
	}

	function stdinDataListener(data) {
		logger.write(data)
	}
	function stdinCloseListener() {
		log('Detected pipe close')
		logger.write('Log pipe close event ' + (new Date).toISOString())
		logger.close(cleanup)
	}

	function cleanup(err) {
		if (err) log('logger.close:', err)
		process.stdin.removeListener('data', stdinDataListener)
		process.stdin.removeListener('close', stdinCloseListener)
		process.stdin.pause()
		logger = null
		shutdown()
	}

	function shutdown() {
		apprunner.shutdown()
	}
}
732304
public function shutdownHandler()
    {
        $error = error_get_last();

        if(!is_null($error)) {
            $this->exceptionHandler(new FatalErrorException($error['message'], $error['type'], 0, $error['file'], $error['line'], 0));
        }
    }
914519
static void terminateClient( IMessagingClient client, String errorMessage, Logger logger ) {

		try {
			logger.fine( "The reconfigurable client is requesting its internal connection to be closed." );
			if( client != null )
				client.closeConnection();

		} catch( Exception e ) {
			logger.warning( errorMessage + " " + e.getMessage());
			Utils.logException( logger, e );

		} finally {
			// "unregisterService" was not merged with "closeConnection"
			// on purpose. What is specific to JMX is restricted to this class
			// and this bundle. Sub-classes may use "closeConnection" without
			// any side effect on the JMX part.
			if( client instanceof JmxWrapperForMessagingClient )
				((JmxWrapperForMessagingClient) client).unregisterService();
		}
	}
675472
def setup_raven():
    ''''''
    pcfg = AppBuilder.get_pcfg()
    from raven.handlers.logging import SentryHandler
    from raven import Client
    from raven.conf import setup_logging
    client = Client(pcfg['raven_dsn'])
    handler = SentryHandler(client)
    # TODO VERIFY THIS -> This is the way to do it if you have a paid account, each log call is an event so this isn't going to work for free accounts...
    handler.setLevel(pcfg["raven_loglevel"])
    setup_logging(handler)
    return client
1292500
def main():
    """"""

    sentry_dsn = os.environ.get('POLYSH_SENTRY_DSN')

    if sentry_dsn:
        from raven import Client
        client = Client(
            dsn=sentry_dsn,
            release='.'.join(map(str, VERSION)),
            ignore_exceptions=[
                KeyboardInterrupt
            ]
        )

        try:
            run()
        except Exception:
            client.captureException()

    else:
        run()
679245
protected void teardown() throws Exception {
    logger.fine("shutting down channels");
    for (ManagedChannel channel : channels) {
      channel.shutdown();
    }
    logger.fine("shutting down server");
    server.shutdown();
    if (!server.awaitTermination(5, TimeUnit.SECONDS)) {
      logger.warning("Failed to shutdown server");
    }
    logger.fine("server shut down");
    for (ManagedChannel channel : channels) {
      if (!channel.awaitTermination(1, TimeUnit.SECONDS)) {
        logger.warning("Failed to shutdown client");
      }
    }
    logger.fine("channels shut down");
  }
1185783
protected function _initOb()
    {
        register_shutdown_function(array($this, 'shutdown'));

        $this->_alerts = new Horde_Imap_Client_Base_Alerts();
        // @todo: Remove (BC)
        $this->_alerts->attach($this);

        $this->_debug = ($debug = $this->getParam('debug'))
            ? new Horde_Imap_Client_Base_Debug($debug)
            : new Horde_Support_Stub();

        // @todo: Remove (BC purposes)
        if (isset($this->_init['capability']) &&
            !is_object($this->_init['capability'])) {
            $this->_setInit('capability');
        }

        foreach (array('capability', 'search_charset') as $val) {
            if (isset($this->_init[$val])) {
                $this->_init[$val]->attach($this);
            }
        }
    }