forked from cozy/cozy-calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.coffee
executable file
·33 lines (28 loc) · 1.04 KB
/
server.coffee
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
#!/usr/bin/env coffee
start = (port, callback) ->
require('americano').start
name: 'Calendar'
port: port
host: process.env.HOST or "0.0.0.0"
root: __dirname
, (app, server) ->
User = require './server/models/user'
localization = require './server/libs/localization_manager'
Realtimer = require 'cozy-realtime-adapter'
realtime = Realtimer server, ['event.*']
realtime.on 'user.*', -> User.updateUser()
User.updateUser (err) -> localization.initialize ->
# Migration scripts. Relies on User.
Event = require './server/models/event'
Alarm = require './server/models/alarm'
Event.migrateAll -> Alarm.migrateAll ->
callback err, app, server
if not module.parent
port = process.env.PORT or 9113
start port, (err) ->
if err
console.log "Initialization failed, not starting"
console.log err.stack
process.exit 1
else
module.exports = start