2014-02-12 05:23:40 -05:00
|
|
|
Settings = require('settings-sharelatex')
|
|
|
|
logger = require 'logger-sharelatex'
|
|
|
|
logger.initialize("web-sharelatex")
|
|
|
|
logger.logger.serializers.user = require("./app/js/infrastructure/LoggerSerializers").user
|
2018-03-09 06:05:17 -05:00
|
|
|
logger.logger.serializers.docs = require("./app/js/infrastructure/LoggerSerializers").docs
|
|
|
|
logger.logger.serializers.files = require("./app/js/infrastructure/LoggerSerializers").files
|
2014-02-12 05:23:40 -05:00
|
|
|
logger.logger.serializers.project = require("./app/js/infrastructure/LoggerSerializers").project
|
2015-12-08 07:14:40 -05:00
|
|
|
if Settings.sentry?.dsn?
|
|
|
|
logger.initializeErrorReporting(Settings.sentry.dsn)
|
|
|
|
|
2014-05-07 10:29:04 -04:00
|
|
|
metrics = require("metrics-sharelatex")
|
|
|
|
metrics.initialize("web")
|
2015-12-03 05:52:06 -05:00
|
|
|
metrics.memory.monitor(logger)
|
2014-02-12 05:23:40 -05:00
|
|
|
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
|
2014-09-02 07:00:33 -04:00
|
|
|
host = Settings.internal.web.host or "localhost"
|
|
|
|
Server.server.listen port, host, ->
|
2015-04-30 10:03:07 -04:00
|
|
|
logger.info "web starting up, listening on #{host}:#{port}"
|
2014-02-12 05:23:40 -05:00
|
|
|
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}"
|