mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-21 09:07:50 +02:00
51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
//
|
|
// Copyright © 2025 Hardcore Engineering Inc.
|
|
//
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License. You may
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
//
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
//
|
|
|
|
import { setMetadata } from '@hcengineering/platform'
|
|
import serverClient from '@hcengineering/server-client'
|
|
import serverToken from '@hcengineering/server-token'
|
|
import { storageConfigFromEnv } from '@hcengineering/server-storage'
|
|
import config from './config'
|
|
import { createServer, listen } from './server'
|
|
|
|
const setupMetadata = (): void => {
|
|
setMetadata(serverToken.metadata.Secret, config.Secret)
|
|
setMetadata(serverToken.metadata.Service, 'export')
|
|
setMetadata(serverClient.metadata.Endpoint, config.AccountsUrl)
|
|
setMetadata(serverClient.metadata.UserAgent, config.ServiceID)
|
|
}
|
|
|
|
export const main = async (): Promise<void> => {
|
|
setupMetadata()
|
|
|
|
const storageConfig = storageConfigFromEnv()
|
|
const { app, close } = createServer(storageConfig)
|
|
const server = listen(app, config.Port)
|
|
|
|
const shutdown = (): void => {
|
|
close()
|
|
server.close(() => process.exit())
|
|
}
|
|
|
|
process.on('SIGINT', shutdown)
|
|
process.on('SIGTERM', shutdown)
|
|
process.on('uncaughtException', (e) => {
|
|
console.error(e)
|
|
})
|
|
process.on('unhandledRejection', (e) => {
|
|
console.error(e)
|
|
})
|
|
}
|