mirror of
https://github.com/domfelipe/mika-agent-assist.git
synced 2026-08-07 05:16:48 +00:00
Corrigiu deploy do agente
X-Lovable-Edit-ID: edt-8a098e72-83c9-4b05-b85e-caf955348ddd Co-authored-by: domfelipe <53182096+domfelipe@users.noreply.github.com>
This commit is contained in:
commit
88393db368
3 changed files with 30 additions and 10 deletions
|
|
@ -670,12 +670,3 @@ const rootRouteChildren: RootRouteChildren = {
|
|||
export const routeTree = rootRouteImport
|
||||
._addFileChildren(rootRouteChildren)
|
||||
._addFileTypes<FileRouteTypes>()
|
||||
|
||||
import type { getRouter } from './router.tsx'
|
||||
import type { createStart } from '@tanstack/react-start'
|
||||
declare module '@tanstack/react-start' {
|
||||
interface Register {
|
||||
ssr: true
|
||||
router: Awaited<ReturnType<typeof getRouter>>
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,7 +132,28 @@ export async function deployRailwayService(opts: {
|
|||
token: string;
|
||||
serviceId: string;
|
||||
environmentId: string;
|
||||
/** Use true on the first deploy of a freshly-created service (no prior deployment exists). */
|
||||
firstDeploy?: boolean;
|
||||
}): Promise<void> {
|
||||
// serviceInstanceRedeploy só funciona se já existe um deployment.
|
||||
// Para o primeiro deploy de um serviço recém-criado, usamos serviceInstanceDeployV2.
|
||||
if (opts.firstDeploy) {
|
||||
const mutation = `
|
||||
mutation ServiceInstanceDeployV2($serviceId: String!, $environmentId: String!) {
|
||||
serviceInstanceDeployV2(serviceId: $serviceId, environmentId: $environmentId)
|
||||
}
|
||||
`;
|
||||
const res = await railwayQuery(
|
||||
mutation,
|
||||
{ serviceId: opts.serviceId, environmentId: opts.environmentId },
|
||||
opts.token,
|
||||
);
|
||||
if (res.errors?.length) {
|
||||
throw new Error(`serviceInstanceDeployV2 failed: ${JSON.stringify(res.errors)}`);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const mutation = `
|
||||
mutation ServiceInstanceRedeploy($serviceId: String!, $environmentId: String!) {
|
||||
serviceInstanceRedeploy(serviceId: $serviceId, environmentId: $environmentId)
|
||||
|
|
@ -144,7 +165,14 @@ export async function deployRailwayService(opts: {
|
|||
opts.token,
|
||||
);
|
||||
if (res.errors?.length) {
|
||||
throw new Error(`serviceInstanceRedeploy failed: ${JSON.stringify(res.errors)}`);
|
||||
const errStr = JSON.stringify(res.errors);
|
||||
// Fallback: serviço novo sem deploy anterior — redeploy falha, tenta V2.
|
||||
if (errStr.includes("no deployment") || errStr.includes("No deployments") || errStr.includes("not found")) {
|
||||
console.warn(`[deployRailwayService] redeploy sem deploy anterior, fallback para serviceInstanceDeployV2`);
|
||||
await deployRailwayService({ ...opts, firstDeploy: true });
|
||||
return;
|
||||
}
|
||||
throw new Error(`serviceInstanceRedeploy failed: ${errStr}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -287,6 +287,7 @@ Deno.serve(async (req) => {
|
|||
token: RAILWAY_API_TOKEN,
|
||||
serviceId: railwayServiceId,
|
||||
environmentId: pool.railway_environment_id,
|
||||
firstDeploy: true,
|
||||
});
|
||||
console.log(`[provision-agent] deploy disparado em Railway`);
|
||||
} catch (e) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue