mirror of
https://github.com/domfelipe/mika-agent-assist.git
synced 2026-08-07 07:56:42 +00:00
Changes
Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com>
This commit is contained in:
parent
7b31f58ac9
commit
fff6a3364c
1 changed files with 26 additions and 6 deletions
|
|
@ -242,12 +242,32 @@ Deno.serve(async (req) => {
|
||||||
let railwayServiceId: string;
|
let railwayServiceId: string;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
railwayServiceId = await createRailwayService({
|
try {
|
||||||
token: RAILWAY_API_TOKEN,
|
railwayServiceId = await createRailwayService({
|
||||||
projectId: pool.railway_project_id,
|
token: RAILWAY_API_TOKEN,
|
||||||
name: serviceName,
|
projectId: pool.railway_project_id,
|
||||||
});
|
name: serviceName,
|
||||||
console.log(`[provision-agent] serviço criado: ${railwayServiceId}`);
|
});
|
||||||
|
console.log(`[provision-agent] serviço criado: ${railwayServiceId}`);
|
||||||
|
} catch (createErr) {
|
||||||
|
const msg = createErr instanceof Error ? createErr.message : String(createErr);
|
||||||
|
// Recover from "service already exists" — provavelmente sobra de attempt anterior
|
||||||
|
if (msg.includes("already exists")) {
|
||||||
|
console.warn(`[provision-agent] serviço já existe, tentando recuperar ID por nome: ${serviceName}`);
|
||||||
|
const existingId = await findRailwayServiceByName({
|
||||||
|
token: RAILWAY_API_TOKEN,
|
||||||
|
projectId: pool.railway_project_id,
|
||||||
|
name: serviceName,
|
||||||
|
});
|
||||||
|
if (!existingId) {
|
||||||
|
throw new Error(`Service "${serviceName}" exists but could not be located via API`);
|
||||||
|
}
|
||||||
|
railwayServiceId = existingId;
|
||||||
|
console.log(`[provision-agent] serviço existente recuperado: ${railwayServiceId}`);
|
||||||
|
} else {
|
||||||
|
throw createErr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
await configureRailwayService({
|
await configureRailwayService({
|
||||||
token: RAILWAY_API_TOKEN,
|
token: RAILWAY_API_TOKEN,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue