Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions infra/scripts/dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
const { spawn, spawnSync } = require('child_process')

function stopServices() {
console.log('\n\n🔵 Stopping Docker...')
spawnSync('npm run services:stop', { stdio: 'inherit', shell: true })
}

try {
let commands = [
'npm run services:up',
'npm run services:wait:database',
'npm run migrations:up'
]

for (const command of commands) {
const result = spawnSync(command, {
stdio: 'inherit',
shell: true
})

if (result.status !== 0) {
throw new Error(
`Command "${command}" failed with exit code ${result.status}`
)
}
}

const next = spawn('next', ['dev'], { stdio: 'inherit', shell: true })

process.on('SIGINT', () => {
stopServices()
process.exit(130)
})

process.on('SIGTERM', () => {
stopServices()
process.exit(143)
})

next.on('close', (code) => {
stopServices()
process.exit(code)
})
} catch (error) {
console.error('🔴 Initialization failed:', error.message)
stopServices()
process.exit(1)
}
4 changes: 2 additions & 2 deletions infra/scripts/wait-for-postgres.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ function checkPostgres() {
return
}

console.log('\n\n🟢 Postgres está pronto e aceitando conexões!\n')
console.log('\n\n🟢 Postgres is ready and accepting connections!\n')
}
}

process.stdout.write('\n\n🔴 Aguardando Postgres aceitar conexões')
process.stdout.write('\n\n⚫ Waiting for Postgres')
checkPostgres()
Loading
Loading