2024-06-19 14:06:36 +00:00
|
|
|
import CodeRepositoryUtil from "./Utils/CodeRepository";
|
2024-06-14 11:09:53 +00:00
|
|
|
import HTTPErrorResponse from "Common/Types/API/HTTPErrorResponse";
|
2024-08-07 21:50:32 +00:00
|
|
|
import logger from "Common/Server/Utils/Logger";
|
2024-06-14 11:09:53 +00:00
|
|
|
import dotenv from "dotenv";
|
2024-06-19 14:06:36 +00:00
|
|
|
import Init from "./Init";
|
2024-08-07 21:50:32 +00:00
|
|
|
import Telemetry from "Common/Server/Utils/Telemetry";
|
2024-08-02 22:35:09 +00:00
|
|
|
|
|
|
|
const APP_NAME: string = "copilot";
|
2024-06-11 12:20:52 +00:00
|
|
|
|
|
|
|
dotenv.config();
|
2024-06-10 16:00:07 +00:00
|
|
|
|
2024-06-14 11:09:53 +00:00
|
|
|
logger.info("OneUptime Copilot is starting...");
|
2024-06-11 12:20:52 +00:00
|
|
|
|
2024-08-02 22:35:09 +00:00
|
|
|
// Initialize telemetry
|
|
|
|
Telemetry.init({
|
|
|
|
serviceName: APP_NAME,
|
|
|
|
});
|
|
|
|
|
2024-06-19 14:06:36 +00:00
|
|
|
Init()
|
2024-06-14 11:09:53 +00:00
|
|
|
.then(() => {
|
|
|
|
process.exit(0);
|
|
|
|
})
|
|
|
|
.catch(async (error: Error | HTTPErrorResponse) => {
|
|
|
|
try {
|
2024-07-15 14:36:23 +00:00
|
|
|
logger.error(error);
|
2024-06-14 11:09:53 +00:00
|
|
|
await CodeRepositoryUtil.discardChanges();
|
|
|
|
|
|
|
|
// change back to main branch.
|
|
|
|
await CodeRepositoryUtil.checkoutMainBranch();
|
|
|
|
} catch (e) {
|
|
|
|
// do nothing.
|
|
|
|
}
|
|
|
|
|
|
|
|
logger.error("Error in starting OneUptime Copilot: ");
|
|
|
|
|
|
|
|
if (error instanceof HTTPErrorResponse) {
|
|
|
|
logger.error(error.message);
|
|
|
|
} else if (error instanceof Error) {
|
|
|
|
logger.error(error.message);
|
|
|
|
} else {
|
|
|
|
logger.error(error);
|
|
|
|
}
|
|
|
|
|
|
|
|
process.exit(1);
|
|
|
|
});
|