proc-killer
v1.0.3
Published
This is a simple cli application that allows you to kill processes given a port number either through flags or an interactive, prompt led cli interaction.
Downloads
23
Readme
Welcome to Proc-Killer
A lightweight package that searches and ends processes for linux/macos
The problem this solves
Have you ever worked on a project and found yourself not being able to interface with node processes? In other words, whether it be using the exec function from node's child process module, automating testing, or just having the need to programmatically control processes because of the lack of interfacing with that process, this simple package solves that problem in a few ways.
Lastly, when I say lack of interfacing I am refering to, primarily, when you, for one use case, run npm run start on a js/ts application and are not able to ctrl + c out of it to consequently end the process.
The 3 ways you can use this package
1. Method one (interactive)
- Going into the package in node_modules, copying and pasting the code, or cloning the repo here
- Running
npm installif cloning the repo - Creating a shortcut for your desktop that allows you to run this script and access the prompt based CLI.
[!NOTE] To assist with this step, I have added pictures/code to walk through the steps of setting this shortcut up to interface with the cli prompts on linux.
- First
cdinto this folder and run the commandchmod +x index.ts(this gives it executable permissions) - Then create a script that invokes this
index.ts. You can add this file anywhere on your machine, just ensure it is an.shfile. - In this .sh file you just created, add the following code:
kill-process.sh
#!/bin/bash
echo "starting application..."
cd path/to/this/package
npm run start
echo "application successfully run"- Then proceed to run the
chmod +x kill-process.shcommand to make this file executable. - Lastly, go to
Desktopdirectory and create a file named Kill-Process.desktop and paste the following code:
[Desktop Entry]
Name=Kill-Process //(or whatever you want)
Exec=gnome-terminal -e "path/to/the/.sh/file/you/just/made"
Type=Application
Terminal=true- Now when you go to double click this desktop shortcut, ensure you give it permission to Launch as program when it prompts you, and with that you are done.
- What this does is create a shortcut which executes a script (.sh file) that executes the index.ts file.
2. Method two
- Going into the package in node_modules, copying and pasting the code, or cloning the repo here
- Running
npm installif cloning the repo - Running one of the following commands:
npm startwith no flags to invoke prompt based interaction with this applicationnpm start -- --<port>Will immediately do a search and end process at that port.npm startjs -- --<port>npx ts-node dev/index.ts --<port>same as above except not calling package.json scripts and using ts-node.
3. Method three
npm install -g proc-killer- Running from your terminal
pkill --<port>to kill a process
or
npm install proc-killerto locally install for projectnpx proc-killer --<port>
