npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

shut-me-down

v1.0.2

Published

Shut down your machine

Downloads

8

Readme

SHUT-DOWN

Pending documentation

Installing package

npm i -g shut-me-down

Important depending on your OS, you need to allow commands to be used without sudo:

# Run 'sudo visudo' and add 
your-username ALL=NOPASSWD: /sbin/shutdown       # OS X and Linux 

Configuring service on Linux or similar

For this purpose we can use systemctl in order to set up a persistent service running on our machine. You can do this with the following command:

sudo nano /etc/systemd/system/shut-me-down.service
## /etc/systemd/system/shut-me-down.service
[Unit]
Description=Shut down API
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=username #1
ExecStart=/usr/local/lib/nodejs/bin/node /usr/local/lib/nodejs/bin/shut-me-down "127.0.0.1" #2 #3

[Install]
WantedBy=multi-user.target

# 1 Make sure that this field its changed for the username of your machine.
# 2 Be sure that your machine match this configuration, if you installed nodejs with node version manager probably won't.
# 3 You can limit where the service listen to the request, for example to limit to request coming from the local machine with localhost you can use 127.0.0.1, if this argument is not present 0.0.0.0 it's used by default, this means that the service will listen to any request coming from any internet interface.

Once you have created the systemd service you can run it with the following command

## If you used a different name for the service file you need to use it here
sudo systemctl start shut-me-down.service
## Check the execution status
sudo systemctl status shut-me-down.service

The status should return an output like this: Status image

If is not the case, and you get an error you will need to resolve the issues with the logs shown at the bottom of the status log or you can see the complete logs with the following command.

sudo tail -n 40 -f /var/log/syslog 

If the service it's running succesfully you should be able to have the port 5709 open to your API, you can check it with the following command:

sudo netstat -onatup | grep 5709
#tcp        0      0 0.0.0.0:5709            0.0.0.0:*               LISTEN      31025/node           off (0.00/0/0)

USAGE

The application listens on the selected ip, and the port 5709 You can test that the service woks by sending a POST to the url http://your.choosen.ip:5709/halt. If you want to test it from your terminal this command will help you:

## Remember that you need to change the host for your the IP that requires your specific case, if the request comes from the same machine you cans use localhost.
## But if the request comes from other device you will ned to use the ip of the device running the service.

curl -d '' http://localhost:5709/halt ## This will power off your device if it's correctly configured.