-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.coffee
More file actions
52 lines (36 loc) · 1.54 KB
/
Copy pathindex.coffee
File metadata and controls
52 lines (36 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
require("source-map-support").install()
merge = require("lodash.merge")
run = require("childish-process")
class DBin # singleton
it = null
cfg: {}
@use: (opts) ->
# Note: calling use again could be made meaningful (e.g. upgrade / restart)
unless it?
unless opts?.defaults is false
@cfg = require("./defaults.json")
merge(@cfg, opts)
home = if @cfg.homeDir then require("home-dir").directory + "/" else ""
base_path = "#{home}#{@cfg.located}/datomic-#{@cfg.edition}-#{@cfg.version}"
alias_uri = "#{@cfg.rest.alias} #{@cfg.transactor.uri}"
unless @cfg.transactor.properties?
protocol = if @cfg.edition is "free" then "free" else "dev"
stp = "#{base_path}/config/samples/#{protocol}-transactor-template.properties"
@cfg.transactor.properties = stp
@cfg.transactor.cmd = "#{base_path}/bin/transactor #{@cfg.transactor.properties}"
@cfg.rest.cmd = "#{base_path}/bin/rest -p #{@cfg.rest.port} #{alias_uri}"
@cfg.rest.uri = "http://localhost:#{@cfg.rest.port}"
@cfg.rest.base = "#{@cfg.rest.uri}/data/#{@cfg.rest.alias}/"
@cfg.console.path ?= "#{base_path}/bin/console" # configurable (to elsewhere?)
@cfg.console.cmd = "#{@cfg.console.path} -p #{@cfg.console.port} #{alias_uri}"
it = new Datomic(@cfg)
class Datomic # private
constructor: (@cfg) -> @
run: (server) ->
serve = @cfg[server]
if serve?
serve.opts ?= {}
console.log(serve.cmd)
run(serve.cmd, serve.opts)
@
module.exports = DBin