NepsenX commited on
Commit
ee83e90
·
verified ·
1 Parent(s): 7a0840c

Update src/index.ts

Browse files
Files changed (1) hide show
  1. src/index.ts +9 -4
src/index.ts CHANGED
@@ -28,9 +28,9 @@ const CONFIG: Config = {
28
  HEALTH_PORT: 7860,
29
  PROD_PORT: 7000,
30
  TEST_PORT: 2000,
31
- ADMIN_EMAIL: 'oracusai.nepsenx@gmail.com',
32
  RESEND_API_KEY: process.env.RESEND_API_KEY || '',
33
- FROM_EMAIL: 'onboarding@resend.dev' // Resend-এর ডিফল্ট sender
34
  };
35
 
36
  if (!CONFIG.GITHUB_PAT) {
@@ -45,7 +45,7 @@ if (!CONFIG.RESEND_API_KEY) {
45
  const resend = CONFIG.RESEND_API_KEY ? new Resend(CONFIG.RESEND_API_KEY) : null;
46
 
47
  // ============================================================
48
- // ইমেইল ফাংশন (Resend API - SMTP ল!)
49
  // ============================================================
50
  async function sendEmail(subject: string, text: string): Promise<void> {
51
  if (!resend) {
@@ -206,7 +206,8 @@ async function checkAndUpdate(): Promise<void> {
206
  testVersionPath = null;
207
 
208
  console.log(`✅ Successfully deployed V2 (${latestSha}) on port ${CONFIG.PROD_PORT}`);
209
- await sendEmail('Deployment Successful', `Version ${latestSha} is now LIVE on port 7000.`);
 
210
 
211
  } catch (error: any) {
212
  console.error('❌ Deployment failed:', error);
@@ -214,6 +215,7 @@ async function checkAndUpdate(): Promise<void> {
214
  testProcess.kill('SIGTERM');
215
  setTimeout(() => { if (!testProcess?.killed) testProcess?.kill('SIGKILL'); }, 2000);
216
  }
 
217
  await sendEmail('Deployment FAILED', `Error: ${error.message}. Port 7000 is unchanged.`);
218
  if (prodProcess) console.log('🔄 Keeping old version running.');
219
  else console.log('⚠️ No previous version available.');
@@ -254,6 +256,9 @@ server.listen(CONFIG.HEALTH_PORT, '0.0.0.0', () => {
254
  checkAndUpdate();
255
  });
256
 
 
 
 
257
  process.on('uncaughtException', (err) => {
258
  console.error('💥 Uncaught Exception:', err);
259
  sendEmail('CRASH - Uncaught Exception', err.stack || err.message);
 
28
  HEALTH_PORT: 7860,
29
  PROD_PORT: 7000,
30
  TEST_PORT: 2000,
31
+ ADMIN_EMAIL: 'arafatislamlam15@gmail.com', // ✅ আপনার ভেরিফাইড ইমেইল
32
  RESEND_API_KEY: process.env.RESEND_API_KEY || '',
33
+ FROM_EMAIL: 'onboarding@resend.dev'
34
  };
35
 
36
  if (!CONFIG.GITHUB_PAT) {
 
45
  const resend = CONFIG.RESEND_API_KEY ? new Resend(CONFIG.RESEND_API_KEY) : null;
46
 
47
  // ============================================================
48
+ // ইমেইল ফাংশন (শুধু ব্যর্থত/ক্র্যাশঠাবে)
49
  // ============================================================
50
  async function sendEmail(subject: string, text: string): Promise<void> {
51
  if (!resend) {
 
206
  testVersionPath = null;
207
 
208
  console.log(`✅ Successfully deployed V2 (${latestSha}) on port ${CONFIG.PROD_PORT}`);
209
+ // সফল ডিপ্লয়মেন্টে ইমেইল বন্ধ করা হয়েছে
210
+ // await sendEmail('Deployment Successful', `Version ${latestSha} is now LIVE on port 7000.`);
211
 
212
  } catch (error: any) {
213
  console.error('❌ Deployment failed:', error);
 
215
  testProcess.kill('SIGTERM');
216
  setTimeout(() => { if (!testProcess?.killed) testProcess?.kill('SIGKILL'); }, 2000);
217
  }
218
+ // ✅ ব্যর্থ ডিপ্লয়মেন্টে ইমেইল পাঠানো হবে
219
  await sendEmail('Deployment FAILED', `Error: ${error.message}. Port 7000 is unchanged.`);
220
  if (prodProcess) console.log('🔄 Keeping old version running.');
221
  else console.log('⚠️ No previous version available.');
 
256
  checkAndUpdate();
257
  });
258
 
259
+ // ============================================================
260
+ // ✅ ক্র্যাশ হলেই ইমেইল পাঠাবে
261
+ // ============================================================
262
  process.on('uncaughtException', (err) => {
263
  console.error('💥 Uncaught Exception:', err);
264
  sendEmail('CRASH - Uncaught Exception', err.stack || err.message);