I've had reports of issues in my sunny plugin which outputs a trace as follows:
files = this.getDatabase().findAllLive(query, sorting, paging);
TypeError: Cannot call method 'findAllLive' of null
at DocPad.getFiles (/private/tmp/derptest/node_modules/docpad/out/lib/docpad.js:431:34)
at doUpload (/private/tmp/derptest/node_modules/docpad-plugin-sunny/sunny.plugin.js:54:19)
at null.<anonymous> (/private/tmp/derptest/node_modules/docpad-plugin-sunny/sunny.plugin.js:99:16)
at EventEmitter.emit (events.js:98:17)
at AuthenticatedRequest.processResults (/private/tmp/derptest/node_modules/docpad-plugin-sunny/node_modules/sunny/lib/request.js:453:10)
at IncomingMessage.<anonymous> (/private/tmp/derptest/node_modules/docpad-plugin-sunny/node_modules/sunny/lib/request.js:427:16)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at process._tickDomainCallback (node.js:459:13)
An error occured within the child DocPad instance: exited with a non-zero status code
Keeping in mind that this plugin has worked fine in the past, something appears to be wrong or changed in regards to Docpad's internals.
The Docpad instance that getDatabase() is being called from is the same instance that's attached to the plugin when the constructor is called by Docpad.
The call in my code can be viewed here just in case it's something on my end.
It looks like this is because _stayAlive keeps the default value of false for the generate command in https://github.com/bevry/docpad/blob/master/src/lib/interfaces/console.coffee#L128 and so it destroys the database before sunny is done uploading files.
I'd imagine there's a good away around this, I know that https://github.com/docpad/docpad-plugin-ghpages uses it's own command, deploy-ghpages instead of piggybacking on the generate command, so that might be the best option for sunny. (It actually keeps _stayAlive set to false, it just waits until everything is done uploading before calling the next() callback.)
Looking at your writeAfter event I notice its not calling the next handler which should be fired if not null...this handler lets docpad task management continue processing..this is especially sensitive when running in generate mode because the docpad process will quit.
A very simple writeAfter would look like this
writeAfter: (opts, next) ->
@pflannery thanks for that, I added it in and the issue seems to be resolved. I would have added this if I had any idea that handler existed. Unfortunately I've never been able to find a particularly good source of documentation for the Docpad plugin system, especially given the changes that seem to happen...
@nfriedly I just switched to using a command line option. You trigger it with docpad deploy-sunny now :)