feat(daemon): add getDaemonProcessId helper

This commit is contained in:
George Lima 2019-05-30 19:01:51 -03:00
parent f2ff156d8e
commit b77bffe621
1 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,17 @@
// @flow
import fs from 'fs';
import path from 'path';
import { getZcashFolder } from './get-zcash-folder';
const ZCASH_PID_FILE = 'zcashd.pid';
export const getDaemonProcessId = (zcashPath?: string) => {
try {
const myPath = zcashPath || getZcashFolder();
const buffer = fs.readFileSync(path.join(myPath, ZCASH_PID_FILE));
const pid = Number(buffer.toString().trim());
return pid;
} catch (err) {
return null;
}
};