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

rust-x-server-stats

v0.1.2

Published

A simple web server to display server stats over HTTP and Websockets

Downloads

1

Readme

x-server-stats

A simple web server(and library) to display server stats over HTTP and Websockets/SSE or stream it to other systems. x-server(in x-server-stats) is not to be confused with X Window System.

Getting started

Installing the crate
$ cargo install x-server-stats
Installing via npm

You can also install x-server-stats via npm, the npm install command will install rust and the x-server-stats binary in your path. This is useful if you want to get started quickly via npm. But we recommend to go with the cargo install command. The npm package is called rust-x-server-stats

$ npm install -g rust-x-server-stats
Installing Rust

You can install Rust by following the instructions from the rust lang website. The command to install rust using bash looks like below on the website, it's always advisable to follow the instructions on the official website. We don't recommend using the command below as it may not be the latest version and other repos can have malicious bash script as well.

# Just for reference, please always head over to the official website for the instructions.
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Install PostgreSQL 14

You can install PostgreSQL 14 by following the instructions from the PostgreSQL website. We use PostgreSQL 14 for the database, you can use any other databases as well, but we don't provide any support for other databases as of now(please raise an issue if you have a usecase for some other database).

# Just for reference, please always head over to the official homebrew/postgres website for the instructions for your OS.
$ brew install postgresql@14
Setting up environment variables

You need to export below environment variables to run the server. The environment variables prefixed with PG are for PotsgreSQL database. Currently, only PostgreSQL is supported for storing stats.

export SERVER_ADDR=localhost:8082
export PG__USER=PG_USERNAME
export PG__PASSWORD=PG_PASSWORD
export PG__HOST=PG_HOST_URL
export PG__PORT=5432
export PG__DBNAME=PG_DB_NAME
export PG__POOL__MAX_SIZE=20
export BASE_ADDR=http://localhost:8082
Building(and running) the application

Before running the application, you need to build it. You can do this by running the following command:

$ cargo build --release 

Run the binary with the following command:

$ ./target/release/x-server-stats
Running the application directly

You can run the application directly by running the following command:

$ cargo run --release
Running the application with Docker

First copy the Dockerfile.example file to Dockerfile and fill in the environment variables. Then run the below commands to build and run the Docker image.

$ docker build -t x-server-stats .
$ docker run -p 8082:8082 x-server-stats

Features

Web page for server stats

TODO - Need to work on this. The web page will be built using just HTML, CSS, JS with the whole page under 14KB gzipped and minified(due to initcwnd of TCP on linux servers).

Request throttling

x-server-stats uses actix-governor to throttle incoming requests based on IP address. The config is present at src/main.rs and can be changed accordingly. Throttling is important if you don't want to overwhelm the server with too many requests by internal systems. We plan to make this configurable in the future, so you don't have to build from source to change the config.