Restart a frozen esky app
        Can also restart if the program is being run as a script
        passes restarted as an argument to the restarted app
189013
def app_restart(cls):
        '''
        
        '''
        logging.debug('In restarter')
        executable = sys.executable.split(os.sep)[-1]
        if os.name == 'nt':
            logging.info('executable is is %s' % executable)
            # restart works here when testing compiled version only
            if executable != 'python.exe':
                boot_strap_path = cls.esky_bootstrap_path()
                bootstrap_file = os.path.join(boot_strap_path, executable)
                logging.info('Bootstrap file for restart: %s' % bootstrap_file)

                subprocess.Popen(
                    [os.path.join(bootstrap_file, bootstrap_file), 'restarted'])
925592
def restart_with_reloader(self):
        
        while True:
            LOGGER.info('Restarting with %s reloader' % self.name)
            args = _get_args_for_reloading()
            new_environ = os.environ.copy()
            new_environ[PULSAR_RUN_MAIN] = 'true'
            exit_code = subprocess.call(args, env=new_environ, close_fds=False)
            if exit_code != EXIT_CODE:
                return exit_code
1262552
def reboot(*args):
    
    args = list(sys.argv) + list(args)
    if args[0] == 'python' or not args[0]:
        args[0] = BIN_PYTHON
    elif os.path.basename(sys.argv[0]) in ['lore', 'lore.exe']:
        args[0] = BIN_LORE
    try:
        os.execv(args[0], args)
    except Exception as e:
        if args[0] == BIN_LORE and args[1] == 'console' and JUPYTER_KERNEL_PATH:
            print(ansi.error() + ' Your jupyter kernel may be corrupt. Please remove it so lore can reinstall:\n $ rm ' + JUPYTER_KERNEL_PATH)
        raise e
1312583
function start(options, callback) {
  const args = utils.getArgs(options, [config], callback);

  app.set("config", args.options);
  server.listen(args.options.port, args.options.ip, function() {
    return args.callback(null);
  }).on("error", function(err) {
    if (err.code === "EADDRINUSE") {
      return args.callback(err);
    }
    console.error(err);
  });
}
80917
def restart(self, start_from=1, occupied=[]):
        

        # initial ID
        self.top = start_from - 1

        # occupied IDs
        self._occupied = sorted(occupied, key=lambda x: x[0])

        # main dictionary storing the mapping from objects to variable IDs
        self.obj2id = collections.defaultdict(lambda: self._next())

        # mapping back from variable IDs to objects
        # (if for whatever reason necessary)
        self.id2obj = {}
72352
def accept(self, evt):
        
        # determine if application is a script file or frozen exe (pyinstaller)
        frozen = getattr(sys, 'frozen', False)
        if frozen:
            app_file = sys.executable
        else:
            app_file = PathStr(__main__.__file__).abspath()

        if self.cb_startmenu.isChecked():
            # TODO: allow only logo location
            # icon = app_file.dirname().join('media', 'logo.ico')
            StartMenuEntry(self.name, app_file, icon=self.icon,
                           console=False).create()

        if self.cb_mime.isChecked():
            # get admin rights
            if not isAdmin():
                try:
                    # run this file as __main__ with admin rights:
                    if frozen:
                        cmd = "from %s import embeddIntoOS\nembeddIntoOS('%s', '%s', '%s')" % (
                            __name__, '', self.ftype, self.name)
                        # in this case there is no python.exe and no moduly.py to call
                        # thats why we have to import the method and execute it
                        runAsAdmin((sys.executable, '-exec', cmd))
                    else:
                        runAsAdmin((sys.executable, __file__,
                                    app_file, self.ftype, self.name))
                except:
                    print('needs admin rights to work')
            else:
                embeddIntoOS(app_file, self.ftype, self.name)

        QtWidgets.QDialog.accept(self)
1245789
def restart(self, password=''):
        
        with self.lock:
            self.send('RESTART :%s' % password, error_check=True)
1297877
def start_app(self, bundle_id):
        '''
        
        '''
        idevicedebug = must_look_exec('idevicedebug')

        # run in background
        kwargs = {'stdout': subprocess.PIPE, 'stderr': subprocess.PIPE}
        if sys.platform != 'darwin':
            kwargs['close_fds'] = True
        return subprocess.Popen([idevicedebug, "--udid", self.udid, 'run', bundle_id], **kwargs)
689249
def app_start_service(self, *args) -> None:
        ''''''
        _, error = self._execute('-s', self.device_sn,
                                 'shell', 'am', 'startservice', *args)
        if error and error.startswith('Error'):
            raise ApplicationsException(error.split(':', 1)[-1].strip())
315495
def _restart():
    ''''''
    if _restart_cb:
        # https://github.com/formwork-io/lazarus/issues/2
        if _restart_cb() is not None:
            # restart cancelled
            return True

    def down_watchdog():
        _observer.stop()
        _observer.join()

        if _close_fds:
            # close all fds...
            _util.close_fds()

        # declare a mulligan ;)
        if _restart_func:
            _restart_func()
            _deactivate()
        else:
            _util.do_over()

    _util.defer(down_watchdog)
    return False
691577
def reboot(name, call=None):
    '''
    
    '''
    if call != 'action':
        raise SaltCloudSystemExit(
            'The restart action must be called with -a or --action.'
        )

    data = show_instance(name, call='action')
    if data.get('status') == 'off':
        return {'success': True,
                'action': 'stop',
                'status': 'off',
                'msg': 'Machine is already off.'}

    ret = query(droplet_id=data['id'],
                command='actions',
                args={'type': 'reboot'},
                http_method='post')

    return {'success': True,
            'action': ret['action']['type'],
            'state': ret['action']['status']}
858283
async function reset () {
    // catch async errors
    try {
        if (immutableApp && immutableApp.server && immutableApp.started) {
            await stop()
        }
        // create global app instance with defaults set
        immutableApp = global.__immutable_app__ = _.cloneDeep(defaultGlobalConfig)
        // create new express app
        immutableApp.express = express()
    }
    catch (err) {
        throw err
    }
}
1279485
function restartAppFromWatching(err) {
		updateWatcherCount()
		if (err) self.emit('error', err)
		if (dashboard.state !== 'stop') {
			log('Restarting ' + conf.name + ' due to file watch trigger')
			appLink.afterThat('restart')
		} else log('Watcher restart ignored in stop state')
	}
1036378
def restart_instance(self, instance):
        
        params = {'state': 'restarted'}
        url = '/instances/{}'.format(instance)
        self.patch_proto(url, params=params)
1351955
function restartOnProcess( index ) {
  log( 'Attempting to restart ' + index + '...' );

  // generate delegate function to pass with proper contexts.
  var startRequest = (function(context, index) {
    return function(cb) {
        startForeverWithIndex.call(context, index, cb);
    };
  }(this, index));

  done = this.async();
  findProcessWithIndex( index, function(process) {
    if(typeof process !== 'undefined') {
      log(forever.format(true,[process]));
      forever.restart(index, false);
      done();
    }
    else {
      log(index + ' not found in list of processes in forever. Starting new instance...');
      startRequest(done);
    }
  });
}
57390
async function start ({latest, message, name, version}) {
	if (beenthere) {
		return;
	}

	beenthere = true;

	console.log( // eslint-disable-line no-console
		box({
			latest,
			message,
			name,
			version,
		})
	);

	const Confirm = require('prompt-confirm');
	const confirmed = await new Confirm(
		`install ${name.yellow} version ${latest.yellow} globally?`
	).run();

	if (!confirmed) {
		process.exit(); // eslint-disable-line no-process-exit
	}

	await require('../install-latest')(name);
	process.exit(); // eslint-disable-line no-process-exit
}
1078528
def _app_base_start(self, option: str, args: list or tuple) -> None:
        '''
        
        '''
        _, error = self._execute('-s', self.device_sn,
                                 'shell', 'am', 'start', option, *args)
        if error and error.startswith('Error'):
            raise ApplicationsException(error.split(':', 1)[-1].strip())