View dsl-print
#!/usr/bin/env lua
--[[
dsl-print [some.dsl]
Example of a lua DSL language, that can use function call or assignment to define
keys, and uses call sequence to implicitly define nesting.
]]
function dsl(code, file)
local loaded, estr = loadstring(code, file)
View dsl.lua
print"TABLE"
function directory(path)
print("directory", path)
return function(attrs)
for key,value in pairs(attrs) do
print("", key, value)
end
end
View cluster-exit.js
var cluster = require('cluster')
, net = require('net');
if (cluster.isMaster) {
console.log('master: node version', process.version);
var worker = cluster.fork();
worker.on('online', function() {
console.log('master: on worker/online');
});
View exit-with-signal.js
assert = require('assert')
cluster = require('cluster');
if(cluster.isMaster) {
worker=cluster.fork();
worker.on('exit', function(code, signal) {
console.log('worker on exit', code, signal, 'process.exitCode', worker.process.exitCode)
})
worker.on('online', function() {
console.log('worker pid', worker.process.pid)
worker.kill('SIGTERM')
View publish 2.0.1
sam@samtu:~/w/sn/slc (release/2.0.0 *% u=) % npm install -g strong-slc
npm http GET https://registry.npmjs.org/strong-slc
npm http 304 https://registry.npmjs.org/strong-slc
npm http GET https://registry.npmjs.org/strong-slc/-/strong-slc-2.0.0.tgz
npm http 404 https://registry.npmjs.org/strong-slc/-/strong-slc-2.0.0.tgz
npm ERR! fetch failed https://registry.npmjs.org/strong-slc/-/strong-slc-2.0.0.tgz
npm ERR! Error: 404 Not Found
npm ERR! at WriteStream.<anonymous> (/usr/local/stow/node/lib/node_modules/npm/lib/utils/fetch.js:57:12)
npm ERR! at WriteStream.EventEmitter.emit (events.js:117:20)
npm ERR! at fs.js:1596:14
View gist:7534247
sam@samtu:~/w/sn/slc (release/2.0.0 % u=) % npm publish
npm http PUT https://registry.npmjs.org/strong-slc
npm http 201 https://registry.npmjs.org/strong-slc
npm http GET https://registry.npmjs.org/strong-slc
npm http 200 https://registry.npmjs.org/strong-slc
npm http PUT https://registry.npmjs.org/strong-slc/-/strong-slc-2.0.0.tgz/-rev/1-3087bd76554a3769731e0808c6daec05
npm http 201 https://registry.npmjs.org/strong-slc/-/strong-slc-2.0.0.tgz/-rev/1-3087bd76554a3769731e0808c6daec05
npm http PUT https://registry.npmjs.org/strong-slc/2.0.0/-tag/latest
npm http 201 https://registry.npmjs.org/strong-slc/2.0.0/-tag/latest
+ strong-slc@2.0.0
View -
var cluster = require('cluster')
var net = require('net');
var spawn = require('child_process').spawn;
if(cluster.isMaster) {
cluster.fork()
cluster.on('exit', function() {
//cluster.disconnect(); // if .disconnect() is called, it closes the serverHandlers
View -
assert = require('assert')
cluster = require('cluster');
if(cluster.isMaster) {
worker=cluster.fork();
worker.on('online', function() {
// pause, to give worker time to establish signal handler
setTimeout(function() {
worker.process.kill('SIGTERM')
}, 100);
});
View cluster-disconnect-message.js
var cluster = require('cluster');
if(cluster.isMaster) {
cluster.fork()
.on('online', function() {
this.disconnect();
});
} else {
process.on('internalMessage', function(msg) {
console.log('internalMsg', msg);
View d.js
var domain = require('domain');
d = domain.create();
d.enter()
d.on('error', function(er) {
d.exit();
console.log('hmm, er');
process.nextTick(function() {
throw er;
});
});