1.2.1 • Published 5 months ago

@anandacahya/steviour v1.2.1

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

Steviour

Steviour

npm version npm downloads

Steviour is a Node.js-based CLI tool designed to generate server configuration files (steviour.json) and manage application runtimes using a lightweight sharding system. It spawns multiple process instances based on your selected runtime/compiler (e.g., Node.js, Python, Ruby). Steviour features automatic restarts on failure and displays system information at startup, making it ideal for running sharded or multi-process applications such as bots, microservices, or background workers across multiple CPU cores.


Installation

npm i steviour -g

Getting Started

Initialize Configuration

Use the following command to generate an initial server configuration in your project:

Command

steviour.js init [compiler]

Example:

steviour init --serverName=asia-1

This will generate a default steviour.json file like this:

{
  "serverName": "DESKTOP-TBC69PH",
  "name": "Backend-Odading",
  "author": "ananda",
  "main": "index.js",
  "shardScheme": {
    "total": 1
  }
}

You can replace main with script if using a custom runtime:

{
  "script": "python index.py"
}

Or another language:

{
  "script": "ruby index.rb"
}

Positional Arguments

  • compiler: Specifies the programming language or compiler to use. Options: "node", "python", "ruby" Default: "node"

Options

OptionAliasDescriptionTypeDefault
--versionDisplay the current version of steviour.jsboolean
--helpShow help messageboolean
--serverName-sSet the server name manuallystring
--shardLengthSet the number of total shardsnumber
--force-fForce overwrite if a configuration file already existsbooleanfalse

Usage Examples

# Initialize with the default (Node.js)
steviour.js init

# Initialize with Python
steviour.js init python

# Initialize with server name and specific shard count
steviour.js init node -s asia1 --shardLength 5

# Force initialization (overwrite existing config)
steviour.js init --force

Configuration File (steviour.json)

Here’s a complete example configuration:

{
  "serverName": "DESKTOP-TBC69PH",
  "name": "Backend-Odading",
  "author": "ananda",
  "main": "index.js",
  "compiler": "node",
  "shardScheme": {
    "total": 1,
    "delay": 4000
  },
  "autoRestart": true,
  "restartDelay": 2500
}

Configuration Fields Explained:

  • main: Entry file for Node.js (use script for other runtimes)
  • compiler: Language runtime used (node, python, ruby)
  • shardScheme.total: Total number of shards to spawn
  • shardScheme.delay: Delay between spawning each shard (in ms)
  • autoRestart: Automatically restart the process on failure (default: true)
  • restartDelay: Delay before restarting a failed process (in ms)

Shard Environment Variables

When your app runs, Steviour sets the following environment variables:

ENV VariableDescriptionType
SYSTEM_IDShard IDNumber
SYSTEM_NAMEUnique shard identifierString
SYSTEM_SERVERNAMEHostname / server nameString
SYSTEM_SHARDLENGTHTotal number of shardsNumber

Running Steviour

Run the application from your project directory:

steviour run

Running a Specific Shard

To run a specific shard manually (ignoring the shardScheme.total):

steviour run --shardId=12

Useful for custom shard managers or debugging single shards.

Development Mode

Enable auto-restart on file changes (great for development and testing):

steviour run --dev

Example usage in your code

Example Code Using Steviour

Below are simple runtime examples in Node.js and Python that can be managed using Steviour with environment-based sharding.


Node.js Example (index.js)
// index.js
console.log('🟢 Node Shard Running');
console.log('🧩 Environment Info:');
console.log(`- SYSTEM_ID: ${process.env.SYSTEM_ID}`);
console.log(`- SYSTEM_NAME: ${process.env.SYSTEM_NAME}`);
console.log(`- SYSTEM_SERVERNAME: ${process.env.SYSTEM_SERVERNAME}`);
console.log(`- SYSTEM_SHARDLENGTH: ${process.env.SYSTEM_SHARDLENGTH}`);

// Simulate workload
setInterval(() => {
  console.log(`Shard ${process.env.SYSTEM_ID} is doing work...`);
}, 3000);
Sample steviour.json Configuration for Node.js:
{
  "serverName": "localhost-node",
  "name": "NodeExample",
  "author": "ananda",
  "main": "index.js",
  "compiler": "node",
  "shardScheme": {
    "total": 3,
    "delay": 2000
  },
  "autoRestart": true,
  "restartDelay": 1000
}

Python Example (index.py)
# index.py
import os
import time

print("🟢 Python Shard Running")
print("🧩 Environment Info:")
print(f"- SYSTEM_ID: {os.getenv('SYSTEM_ID')}")
print(f"- SYSTEM_NAME: {os.getenv('SYSTEM_NAME')}")
print(f"- SYSTEM_SERVERNAME: {os.getenv('SYSTEM_SERVERNAME')}")
print(f"- SYSTEM_SHARDLENGTH: {os.getenv('SYSTEM_SHARDLENGTH')}")

# Simulate workload
while True:
    print(f"Shard {os.getenv('SYSTEM_ID')} is doing work...")
    time.sleep(3)
Sample steviour.json Configuration for Python:
{
  "serverName": "localhost-python",
  "name": "PythonExample",
  "author": "ananda",
  "script": "python index.py",
  "compiler": "python",
  "shardScheme": {
    "total": 3,
    "delay": 2000
  },
  "autoRestart": true,
  "restartDelay": 1000
}
1.2.1

5 months ago

1.2.0

5 months ago

1.1.0

5 months ago