mimosa-server-reload v1.1.0
mimosa-server-reload
Overview
This is a Mimosa module for restarting a node server when server-bound assets (like routes, general lib files) change.
For more information regarding Mimosa, see http://mimosajs.com
Note: Version 0.7.0 requires mimosa 0.13.3 or above.
Usage
Install 'mimosa-server-reload' using the mimosa mod:install mimosa-server-reload command. The mimosa-server module is a prereq.
Functionality
The mimosa-server-reload module will point itself at a list of configurable files/folders and when the contents (recursive) of those change, it will work with both the mimosa-server and mimosa-live-reload modules to restart the user's server.
If you are using mimosa-server-reload, as part of restarting your server, this module shuts down the web socket connections that enable live reload so that the server can be closed. It restarts the server-side of the web socket connection, but does not reconnect with the client. So after the server is restarted, you need to refresh the browser to reconnect live reload.
Some prerequisites for this module are:
- Must be installed inside Mimosa, where
mimosa-serveris located - You must be using
mimosa-server - You must start Mimosa using the
--serveror-sflag - You must not being using Mimosa's hosted server. Your
server.defaultServer.enabledvalue should be set to false.
mimosa-live-reload is not a prereq, but this module will work with that one if it is present to shut down socket connections.
Pre-restart Hook
As of version 2.2.14 of Mimosa and 0.9.0 of this module, if your server file (same location as startServer function) has a preMimosaRestart function that has been exported, mimosa-server-restart will call it before it restarts your server. This gives you an opportunity to clean up any resources like connections to databases, etc.
preMimosaRestart will be passed a callback. When everything that needs cleaning up is finished, execute the callback. This module will then execute the restart.
exports.preMimosaRestart = function (callback) {
// Clean stuff up here
callback();
}Default Config
serverReload:
watch:["server.coffee", "server.js", "server.ls", "server.iced", "routes", "src", "lib"]
exclude:[]
validate:truewatch: an array of strings, folders and files whose contents will trigger a server restart when changed. By default all the possible server names generated bymimosa neware included as well as the routes folder, which is also delivered bymimosa new. Also considered defaults are typical source colde libraries:srcandlib. Paths can be relative to the root of your project or absolute.exclude: an array of strings and/or regexs, the list of files and file patterns to exclude from restarting the server. Can be a mix of regexes and strings. ex:ex: [/\.txt$/, "vendor/jqueryui.js"]. Can be left off or made null if not needed. Can be relative to the root of your project or absolute.validate: a boolean, whether or not to validate changed files. When true, the default,mimosa-server-reloadwillrequire()the changed file. If the require fails, because it is invalid CoffeeScript/JavaScript for instance, Mimosa will not attempt to restart the server since the restart will likely fail.validate: truewill cause problems if you pointwatchat non JavaScript files, for instance, server views. If you include yourviewsfolder inwatch, you will want to turnvalidateoff.
11 years ago
11 years ago
11 years ago
11 years ago
12 years ago
12 years ago
12 years ago
12 years ago
12 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago