nodeRunner
<a href="http://noderunner.org/">nodeRunner</a> is a Node.js server app that runs scripts every second, minute, hour or overnight, each group in its own folder.
It's the <a href="http://scripting.com/2014/12/28/forReviewNoderunner.html">first</a> of a series of "server snacks" that came out in early 2015.
<a href="http://noderunner.smallpict.com/2015/01/03/whyINeededNoderunner.html">Dave Winer</a>
How it works
<img src="http://scripting.com/2014/12/28/snacks.png" width="145" height="143" border="0" align="right" alt="A picture named snacks.png">Copy noderunner.js to a folder with a single sub-folder: scripts.
In scripts, there are four sub-folders, everySecond, everyMinute, everyHour, overnight and startup. You can use the examples in the scripts folder here as examples to help you get started.
Any file with a .js extension in those folders are loaded and run when it's their time. All other files are ignored.
The files are not cached, so you can make changes while nodeRunner is running.
They share data through a structure called localStorage, which works more or less like localStorage in browsers. It doesn't have a file size limit, but it's a good idea to keep it small, because it's potentially saved every second.
It automatically creates the folders it needs when it boots up.
Examples
-
Here's a <a href="https://github.com/scripting/noderunner/blob/master/examples/startup/hello.js">Hello World</a> script that runs when nodeRunner starts up.
-
<a href="https://github.com/scripting/noderunner/blob/master/examples/everyMinute/rivertoconsole.js">RiverToConsole</a> runs every minute and checks a JSON file produced by River4, and echoes new items to the console. It's part of a real app that I use to maintain <a href="https://twitter.com/nyt">@NYT</a> on Twitter.
-
<a href="https://github.com/scripting/noderunner/blob/master/examples/overnight/snapshot.js">Snapshot</a> archives the Scripting News feed once a day in a calendar folder structure.
Special folders
-
files contains files that are accessed through three routines provided by nodeRunner: fileExists, readWholeFile and writeWholeFile. Note, you can use any of Node's <a href="http://nodejs.org/api/fs.html">fs</a> routines to read or write to any file on the local system.