mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 14:13:38 -05:00
72af966c9c
* Schedule subscription downgrades to occur at the current term end. If the plan is a downgrade, schedule the subscription change for term end. Use Recurly v3 API subscription change event instead of v2 update subscription. * Add ability for user to revert a pending subscription change In the case where a user has downgraded, but has since decided they'd rather stay on their current plan, we need a way to let them revert. It isn't enough to re-use a subscription change, because Recurly sees it as an attempt to make a change from the current plan to itself. Instead, we use a new dialog and call a new endpoint that has the specific intent of reverting the pending plan change, by calling the removeSubscriptionChange recurly client method. * Add message prompting users to contact support for immediate changes We're showing this in the confirmation modal for a plan change that would occur in the future, and and on the subscription page if a pending change is due. Most users shouldn't need this, but it should help them out if they find an edge case like moving from eg. Student (Annual) to Professional (Monthly) and were expecting to be "upgraded" immediately. GitOrigin-RevId: c5be0efbeb8568ed9caa941aadcef6f6db65c420
71 lines
2.7 KiB
JavaScript
71 lines
2.7 KiB
JavaScript
/* eslint-disable
|
|
max-len,
|
|
*/
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
// Fix any style issues and re-enable lint.
|
|
/*
|
|
* decaffeinate suggestions:
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
* DS207: Consider shorter variations of null checks
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
*/
|
|
const metrics = require('@overleaf/metrics')
|
|
metrics.initialize(process.env.METRICS_APP_NAME || 'web')
|
|
const Settings = require('settings-sharelatex')
|
|
const logger = require('logger-sharelatex')
|
|
const PlansLocator = require('./app/src/Features/Subscription/PlansLocator')
|
|
logger.initialize(process.env.METRICS_APP_NAME || 'web')
|
|
logger.logger.serializers.user = require('./app/src/infrastructure/LoggerSerializers').user
|
|
logger.logger.serializers.docs = require('./app/src/infrastructure/LoggerSerializers').docs
|
|
logger.logger.serializers.files = require('./app/src/infrastructure/LoggerSerializers').files
|
|
logger.logger.serializers.project = require('./app/src/infrastructure/LoggerSerializers').project
|
|
if ((Settings.sentry != null ? Settings.sentry.dsn : undefined) != null) {
|
|
logger.initializeErrorReporting(Settings.sentry.dsn)
|
|
}
|
|
|
|
metrics.memory.monitor(logger)
|
|
|
|
const Server = require('./app/src/infrastructure/Server')
|
|
const mongodb = require('./app/src/infrastructure/mongodb')
|
|
const mongoose = require('./app/src/infrastructure/Mongoose')
|
|
|
|
if (Settings.catchErrors) {
|
|
process.removeAllListeners('uncaughtException')
|
|
process.on('uncaughtException', error =>
|
|
logger.error({ err: error }, 'uncaughtException')
|
|
)
|
|
}
|
|
const port = Settings.port || Settings.internal.web.port || 3000
|
|
const host = Settings.internal.web.host || 'localhost'
|
|
if (!module.parent) {
|
|
// Called directly
|
|
|
|
// We want to make sure that we provided a password through the environment.
|
|
if (!process.env.WEB_API_USER || !process.env.WEB_API_PASSWORD) {
|
|
throw new Error('No API user and password provided')
|
|
}
|
|
|
|
PlansLocator.ensurePlansAreSetupCorrectly()
|
|
|
|
Promise.all([mongodb.waitForDb(), mongoose.connectionPromise])
|
|
.then(() => {
|
|
Server.server.listen(port, host, function () {
|
|
logger.info(`web starting up, listening on ${host}:${port}`)
|
|
logger.info(`${require('http').globalAgent.maxSockets} sockets enabled`)
|
|
// wait until the process is ready before monitoring the event loop
|
|
metrics.event_loop.monitor(logger)
|
|
})
|
|
})
|
|
.catch(err => {
|
|
logger.fatal({ err }, 'Cannot connect to mongo. Exiting.')
|
|
process.exit(1)
|
|
})
|
|
}
|
|
|
|
// handle SIGTERM for graceful shutdown in kubernetes
|
|
process.on('SIGTERM', function (signal) {
|
|
logger.warn({ signal: signal }, 'received signal, shutting down')
|
|
Settings.shuttingDown = true
|
|
})
|
|
|
|
module.exports = Server.server
|