Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jacobbubu/pidfile
Yet another pidfile generator
https://github.com/jacobbubu/pidfile
Last synced: 14 days ago
JSON representation
Yet another pidfile generator
- Host: GitHub
- URL: https://github.com/jacobbubu/pidfile
- Owner: jacobbubu
- License: mit
- Created: 2020-06-11T09:32:29.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T08:36:35.000Z (about 2 years ago)
- Last Synced: 2024-12-14T06:16:18.464Z (about 1 month ago)
- Language: TypeScript
- Size: 1.16 MB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# @jacobbubu/pidfile
[![Build Status](https://github.com/jacobbubu/pidfile/workflows/Build%20and%20Release/badge.svg)](https://github.com/jacobbubu/pidfile/actions?query=workflow%3A%22Build+and+Release%22)
[![Coverage Status](https://coveralls.io/repos/github/jacobbubu/pidfile/badge.svg)](https://coveralls.io/github/jacobbubu/pidfile)
[![npm](https://img.shields.io/npm/v/@jacobbubu/pidfile.svg)](https://www.npmjs.com/package/@jacobbubu/pidfile/)> A simple pidfile generate module (ref. https://github.com/kesla/pidlockfile)
## Usage
``` ts
import * as path from 'path'
import { promises as fs } from 'fs'
import pidlock from '@jacobbubu/pidfile'const main = async () => {
const filename = path.join(__dirname, 'lock.pid')
const unlock = await pidlock(path.join(__dirname, 'lock.pid'), { unlockOnExit: false })
if (unlock instanceof Error) {
// unlock is an Error object withe message 'Lockfile already acquired'
} else {
const pid = await fs.readFile(filename, 'utf8')
console.log({ pidInFile: pid, pid: process.pid })
unlock()
}
}main()
```## Before push
Before pushing the code to GitHub, please make sure that `NPM_TOKEN` is configured in `https://github.com/__your_repo__/settings/secrets`, or you can do this through [`semantic-release-cli`](https://github.com/semantic-release/cli).