Skip to content

Instantly share code, notes, and snippets.

@ndesmic
Last active September 29, 2018 06:06
Show Gist options
  • Save ndesmic/e58426740464c9fd1aa42a532cdfbb9d to your computer and use it in GitHub Desktop.
Save ndesmic/e58426740464c9fd1aa42a532cdfbb9d to your computer and use it in GitHub Desktop.
killport
#! /usr/bin/env node
const util = require("util");
const exec = util.promisify(require("child_process").exec);
const port = process.argv[2];
exec(`lsof -t -i :${port}`)
.then(result => exec(`kill -9 ${result.stdout}`))
.then(() => console.log(`Killed process using port ${port}`))
.catch(e => {
console.log(`Failed. Are you sure there was something using port ${port}?`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment