Last active
September 29, 2018 06:06
-
-
Save ndesmic/e58426740464c9fd1aa42a532cdfbb9d to your computer and use it in GitHub Desktop.
killport
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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