Skip to content

Instantly share code, notes, and snippets.

View baudehlo's full-sized avatar

Matt Sergeant baudehlo

View GitHub Profile
for (var i=0,l=cluster_modules.length; i < l; i++) {
var matches;
if (/^\w+:/.test(cluster_modules[i])) {
var parts = cluster_modules[i].split(':');
var module = parts.shift();
c.use(cluster[module].apply(cluster, parts));
}
else if (matches = /^(\w+)\s+(\{.*\})\s*$/.exec(cluster_modules[i])) {
var module = matches[1];
console.log("Loading cluster module " + module + "( " + matches[2] + ")");
for (var i=0,l=cluster_modules.length; i < l; i++) {
var matches = /^(\w+)\s*(?::\s*(.*))?$/.exec(cluster_modules[i]);
if (!matches) {
Server.logerror("cluster_modules in invalid format: " + cluster_modules[i]);
continue;
}
var module = matches[1];
var params = matches[2];
if (params) {
c.use(cluster[module](JSON.parse(params)));
logger.log = function (level, data) {
var include_stack = config.get('log_includes_trace');
if (include_stack) {
var stack = (new Error()).stack;
var matches = stack.match(/^.*\n.*\n.*\n.*\(.*\/(.*):(\d+):\d+\)/);
if (matches) {
if (matches[1] === 'plugins.js') {
// likely in a plugin, get the next line instead.
var new_matches = stack.match(/^.*\n.*\n.*\n.*\n.*\((.*):(\d+):\d+\)/);
if (new_matches) {
Cleaning /tmp...xargs: xargs.c:450: main: Assertion `bc_ctl.arg_max <= (131072-2048)' failed.
/etc/init.d/bootclean: line 89: 3044 Broken pipe find . -depth -xdev $TEXPR $EXCEPT ! -type d -print0
3045 Aborted | xargs -0r rm -f --
failed (bootclean: Failure cleaning /tmp).
Cleaning /var/run...xargs: xargs.c:450: main: Assertion `bc_ctl.arg_max <= (131072-2048)' failed.
/etc/init.d/bootclean: line 153: 3051 Broken pipe find . ! -xtype d ! -name utmp ! -name innd.pid -print0
var oldPrep = Error.prepareStackTrace;
Error.prepareStackTrace = function (error, structuredStackTrace) {
Error.prepareStackTrace = oldPrep;
if (structuredStackTrace.length < 4) {
return '';
}
var pos = 2;
if (/\/plugins.js/.test(structuredStackTrace[pos].getFileName())) { // && /run_next_hook/.test(structuredStackTrace[pos].getFunctionName())) {
pos = 3;
}

Things commercial MTAs offer that (most) open source MTAs don't:

  • Cluster support
  • Monitoring (including cluster monitoring)
  • Bounce handling
  • Per recipient domain settings

Cluster Support

@baudehlo
baudehlo / test-qmailq.js
Created February 2, 2012 02:24
How writing to qmail-queue should work
var qmailq = childproc.spawn('/var/qmail/bin/qmail-queue');
qmailq.on('exit', function (code) {
console.log("qmail-queue exited with: " + code);
});
qmailq.stdin.write(
"Subject: foo\n" +
"From: Matt <[email protected]>\n" +
"\n" +
matt@ip-:~$ xopen
No command 'xopen' found, did you mean:
Command 'gopen' from package 'gnustep-gui-runtime' (universe)
Command 'open' from package 'console-tools' (universe)
Command 'open' from package 'kbd' (main)
Command 'open' from package 'open.app' (universe)
Command 'wopen' from package 'gworkspace.app' (universe)
Command 'mopen' from package 'moonlight-tools' (universe)
xopen: command not found
matt@ip-:~$ xdg-open
var white_regex =
this.config.get('mail_from.access.whitelist_regex', 'list',
function (re_list) {
if (re_list.length) {
return new RegExp('^(?:' + re_list.join('|') + ')$', 'i');
}
});
exports.execute = function (sql, binds, cb) {
// TODO: query via memcached first (?)
if (!this.db) {
// db not ready yet
if (this.loop_count && this.loop_count > 10) {
throw "Database connection timed out";
}
this.loop_count = this.loop_count || 0;
this.loop_count++;