How to use find-process - 9 common examples

To help you get started, we’ve selected a few find-process examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github machawk1 / wail / wail-core / managers / serviceManager2.js View on Github external
async _maybeFindHeritrixProcess () {
    let {logger} = global
    let findpResults = await findP('name', hFindRegx)
    let hfinder = heritrixFinder(findpResults)
    if (hfinder.found) {
      let {pid, isWails} = hfinder
      // console.log(`there is a heritrix instance running pid=${pid}`)
      if (isWails) {
        // console.log('it is wails')
        try {
          await this._updatePidStore(pid, 'heritrix')
        } catch (error) {
          if (logger) {
            logger.fatal({err: error, msg: serializeError(error)})
          }
          return heritrixLaunchErrorReport(error.message, 'Internal')
        }
        this._monitoring.set('heritrix', pid)
        return {wasError: false}
github jbccollins / metro-monitor / runApp.js View on Github external
const killConflictingApps = async () => {
    portConflictResolutionAttempted = true;
    if (process.env.NODE_ENV !== "production") {
      const list = await find('port', port);
      if (!list.length) {
        console.log(chalk.green(`[server] Port ${port} is free :)`));
      } else {
        list.forEach(({pid, name}) => {
          if (pid !== process.pid) {
            console.log(chalk.cyan(`[server] Killing process ${name} due to conflict on port ${port}.`));
            process.kill(pid);
          }
        })
      }
      // process.kill does not happen immediately so we need to wait just a bit before
      // actually trying to run again.
      setTimeout(start, 100);
    } else {
      console.log(chalk.red('[server] Not killing conflicting apps because in production mode.'));
    }
github ZcashFoundation / zepio / config / daemon / zcashd-child-process.js View on Github external
if (optionsFromZcashConf.rpcport) store.set('rpcport', optionsFromZcashConf.rpcport);
  if (optionsFromZcashConf.rpcuser) store.set('rpcuser', optionsFromZcashConf.rpcuser);
  if (optionsFromZcashConf.rpcpassword) store.set('rpcpassword', optionsFromZcashConf.rpcpassword);

  log('Searching for zcashd.pid');
  const daemonProcessId = getDaemonProcessId(optionsFromZcashConf.datadir);

  if (daemonProcessId) {
    store.set(EMBEDDED_DAEMON, false);
    log(
      // eslint-disable-next-line
        `A daemon was found running in PID: ${daemonProcessId}. Starting Zepio in external daemon mode.`,
    );

    // Command line args override zcash.conf
    const [{ cmd, pid }] = await findProcess('pid', daemonProcessId);

    store.set(DAEMON_PROCESS_PID, pid);

    // We need grab the rpcuser and rpcpassword from either process args or zcash.conf
    const {
      rpcuser, rpcpassword, rpcconnect, rpcport, testnet: isTestnetFromCmd,
    } = parseCmdArgs(
      cmd,
    );

    store.set(
      ZCASH_NETWORK,
      isTestnetFromCmd === '1' || optionsFromZcashConf.testnet === '1' ? TESTNET : MAINNET,
    );

    if (rpcuser) store.set('rpcuser', rpcuser);
github btzr-io / jelly-beats / src / main / index.js View on Github external
app.on('ready', async () => {
  // Main window props
  const windowProps = {
    title: `${app.getName()} ~ ${app.getVersion()}`,
    webPreferences: { webSecurity: false, nodeIntegration: true },
    autoHideMenuBar: true,
  }

  // Create main BrowserWindow when electron is ready
  rendererWindow = createMainWindow(windowProps)

  // Windows WMIC returns lbrynet start with 2 spaces. https://github.com/yibn2008/find-process/issues/18
  const processListArgs = IS_WINDOWS ? 'lbrynet  start' : 'lbrynet start'
  const processList = await findProcess('name', processListArgs)
  const isDaemonRunning = processList.length > 0

  // Start LBRY DAEMON
  if (!isDaemonRunning) {
    daemon = new Daemon()
    daemon.on('exit', () => {
      daemon = null
    })
    daemon.launch()
  }
})
github onderceylan / pwa-asset-generator / src / helpers / browser.ts View on Github external
const LAUNCHER_NOT_INSTALLED_ERROR_CODE = 'ERR_LAUNCHER_NOT_INSTALLED';
  const logger = preLogger(getBrowserInstance.name);

  let browser: Browser;
  let chrome: LaunchedChrome | undefined;

  try {
    chrome = await launchSystemBrowser();
    browser = await getSystemBrowserInstance(chrome, launchArgs);
  } catch (e) {
    // Kill chrome instance manually in case of connection error
    if (e.code === LAUNCHER_CONNECTION_REFUSED_ERROR_CODE) {
      logger.warn(
        `Chrome launcher could not connect to your system browser. Is your port ${e.port} accessible?`,
      );
      const prc = await find('port', e.port);
      prc.forEach(pr => {
        logger.log(
          `Killing incompletely launched system chrome instance on pid ${pr.pid}`,
        );
        process.kill(pr.pid);
      });
    }

    // Inform user that system chrome is not found
    if (e.code === LAUNCHER_NOT_INSTALLED_ERROR_CODE) {
      logger.warn('Looks like Chrome is not installed on your system');
    }

    browser = await getLocalBrowserInstance(launchArgs);
  }
github machawk1 / wail / wail-core / managers / serviceManager3.js View on Github external
_maybeFindHeritrixProcess (didStart, resolve, reject) {
    let {logger} = global
    return findP('name', hFindRegx).then(findResults => {
      let {found, pid, isWails} = heritrixFinder(findResults)
      if (found) {
        console.log(`there is a heritrix instance running pid=${pid}`)
        if (isWails) {
          console.log('it is wails')
          return this._updatePidStore(pid, 'heritrix').then(() => { resolve({wasError: false}) })
            .catch(error => {
              if (logger) {
                logger.fatal({err: error, msg: 'service manager inserting heritrix pid error'})
              }
              resolve(heritrixLaunchErrorReport(error.message, 'Internal'))
            })
        } else {
          console.log('it is not wails')
          resolve(heritrixLaunchErrorReport("Another Heritrix instance not under WAIL's control is in use", 'Launching Heritrix'))
        }
github makeflow / remote-workspace / src / client-host / main.ts View on Github external
async handler() {
      let response = await fetch(`${config.remoteURL}/api/workspaces`, {agent});
      let result = (await response.json()) as {data?: WorkspaceStatus[]};

      let {data: workspaces} = result;

      if (workspaces) {
        sshConfig.update(workspaces);

        let vscodeProcesses = await findProcess('name', /[\\/]code(?:\.exe)?/i);

        if (!vscodeProcesses.length) {
          vscodeStorage.cleanUp(workspaces);
        }
      }

      return result;
    },
  });
github aragon / aragon-cli / packages / cli / src / commands / devchain_cmds / status.js View on Github external
task: async ctx => {
          ctx.portTaken = await isPortTaken(port)
          if (ctx.portTaken) {
            const processData = await find('port', port)
            ctx.processID = processData[0].pid
          }
        },
      },

find-process

find process info by port/pid/name etc.

MIT
Latest version published 3 years ago

Package Health Score

67 / 100
Full package analysis

Popular find-process functions