forked from overleaf/web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.coffee
35 lines (31 loc) · 1.39 KB
/
app.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
34
35
Settings = require('settings-sharelatex')
logger = require 'logger-sharelatex'
logger.initialize("web-sharelatex")
logger.logger.serializers.user = require("./app/js/infrastructure/LoggerSerializers").user
logger.logger.serializers.project = require("./app/js/infrastructure/LoggerSerializers").project
if Settings.sentry?.dsn?
logger.initializeErrorReporting(Settings.sentry.dsn)
metrics = require("metrics-sharelatex")
metrics.initialize("web")
metrics.memory.monitor(logger)
Server = require("./app/js/infrastructure/Server")
argv = require("optimist")
.options("user", {alias : "u", description : "Run the server with permissions of the specified user"})
.options("group", {alias : "g", description : "Run the server with permissions of the specified group"})
.usage("Usage: $0")
.argv
if Settings.catchErrors
process.removeAllListeners "uncaughtException"
process.on "uncaughtException", (error) ->
logger.error err: error, "uncaughtException"
port = Settings.port or Settings.internal?.web?.port or 3000
host = Settings.internal.web.host or "localhost"
Server.server.listen port, host, ->
logger.info "web starting up, listening on #{host}:#{port}"
logger.info("#{require('http').globalAgent.maxSockets} sockets enabled")
if argv.user
process.setuid argv.user
logger.info "Running as user: #{argv.user}"
if argv.group
process.setgid argv.group
logger.info "Running as group: #{argv.group}"