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

persha

v0.2.3

Published

Persistent and Highly Available javascript engine

Downloads

4

Readme

PersHA.js

Build Status npm version

PersHA.js is a persistent and highly available javascript engine. As a javascript interpreter, it has compatible functionality to Node.js. As it's non-functional features, the engine itself has persistence across restarts and can be configured as a part of highly available cluster of triple nodes.

PersHA.js is written in javascript, and works on Node.js.

Installation

npm install -g persha

Prerequisite: node v0.12.x (with other versions it does not work correctly.)

Starting

persha -init

It starts REPL(read-eval-print-loop) interfece. You can run any javascript programs, and results will be shown consequently. To stop REPL, hit ctrl-C twice.

Starting with an application program

persha -init app.js

where app.js is a name of your application program file. To stop your application, just kill the process by hitting ctrl-C.

Restarting

persha -restart

After exiting PersHA.js, you can restart the engine again. It restarts with internal states preserved, and continues suspended REPL or your app.js.

Persistence is assured even after killing the process or even after restarting the computer.

Example 1

persha -init
> x="Hello World"
'Hello World'
>
(^C again to quit)

persha -restart
RECOVERING ...
READY
> x
'Hello World'

This is a simple example showing persistence of the engine. A variable 'x' has its value 'Hello World' persistent across restarts.

Example 2

persha -init
> function y(){console.log("count " + ++x)}
> var x=0
> var id=setInterval(y, 1000)
count 1
count 2
count 3
count 4
(^C again to quit)

persha -restart
RECOVERING ...
READY
count 5
count 6
count 7
> clearInterval(id)

This is an another example showing persistence of the engine. All internal states including a value of 'x', 'id', a function 'y', and interval timer are persistent across restarts.

Practical Example

app.js:

var express=require('express');
var app=express();
var x=100;
app.get('/', function (req, res) {
  res.send('Hello ' + x++);
});
app.listen(3000);
% npm install express
% persha -init app.js &
[1] 2075
% curl http://localhost:3000
Hello 100
% curl http://localhost:3000
Hello 101
% kill 2075
[1]  + terminated  persha -init app.js
% curl http://localhost:3000
curl: (7) Failed to connect to localhost port 3000: Connection refused
% persha -restart &
[1] 2123
% curl http://localhost:3000
Hello 102
% curl http://localhost:3000
Hello 103

This is a more practical example. In app.js, the express module is loaded and a web server is launched at port 3000. You can check web server's 'Hello' responses using curl command. After killing the engine, you cannot get any responses. But after restarting the engine, You can get 'Hello' responses again. Notice that number sequence in response messages continues because a variable 'x' is persistent across restarts.

In general, any pure javascript module can be loaded in PersHA.js provided that the module has been installed in node_modules directory. Module search order is same as Node's one. Once a module is loaded in the engine, it won't be re-read from files even after restarting the engine.

High Availability

This feature is not supported yet in current version.

Multiple Instances

export PERSHA_DATA=path/to/datastore
persha -init
persha -restart

By default, PersHA.js stores executing information in $HOME/.persha directory, and it reads the last executing information from this directory when it restarts. If you want multiple instances to run in parallel, you have to change this directory specifying the PERSHA_DATA enviroment variable.

Supported native modules

Currently following native modules are supported:

'events', 'constants', 'module', 'buffer', 'util', 'assert', 'vm', 'timers', 'stream', 'console', 'fs', 'path', 'net', 'repl', 'readline', 'domain', 'string_decoder', 'http', 'freelist', 'url', 'punycode', 'querystring', 'dns', 'dgram', 'tty', 'crypto', 'os'

Any contribution is welcome

Please let me know bugs/opinions/ideas. Thank you for your contribution.