Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(server): add quick server startup with spawn server and use node…
…mon for dev build
- Loading branch information
Showing
9 changed files
with
62 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module.exports = (config) -> | ||
log = require "#{config.req.helpers}/log" | ||
test = require("#{config.req.helpers}/test")() | ||
|
||
# init server | ||
# =========== | ||
server = {} | ||
|
||
# messages | ||
# ======== | ||
server.msg = | ||
start: "Server started on #{config.ports.server}" | ||
noScripts: 'No application server scripts to load.' | ||
|
||
# add server to config | ||
# ==================== | ||
config.server = server | ||
|
||
# logs | ||
# ==== | ||
# log.json server, 'server =' | ||
|
||
# tests | ||
# ===== | ||
test.log 'true', config.server, 'add server to config' | ||
|
||
# return | ||
# ====== | ||
config | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = (gulp, config) -> | ||
q = require 'q' | ||
spawn = require('child_process').spawn | ||
rbServerFile = config.dist.rb.server.scripts.path | ||
|
||
# register task | ||
# ============= | ||
gulp.task "#{config.rb.prefix.task}spawn-server", -> | ||
defer = q.defer() | ||
server = spawn 'node', [ rbServerFile ] | ||
server.stdout.on 'data', (data) -> | ||
msg = data.toString().trim() | ||
console.log msg.yellow | ||
defer.resolve() if msg.indexOf(config.server.msg.start) isnt -1 | ||
defer.promise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
module.exports = (gulp, config) -> | ||
# task deps | ||
# ========= | ||
taskDeps = ["#{config.rb.prefix.task}nodemon"] | ||
taskDeps = ["#{config.rb.prefix.task}spawn-server"] | ||
taskDepsDev = ["#{config.rb.prefix.task}nodemon"] | ||
|
||
# register task | ||
# ============= | ||
gulp.task "#{config.rb.prefix.task}start-server", taskDeps | ||
gulp.task "#{config.rb.prefix.task}start-server:dev", taskDepsDev | ||
|