Skip to content

Commit 3b6fc6c

Browse files
committed
feat: auto-trace more frequently
1 parent e8c2918 commit 3b6fc6c

6 files changed

Lines changed: 13 additions & 14 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"packageManager": "yarn@4.4.1",
1111
"scripts": {
1212
"deploy": "yarn build && yarn turbo deploy --env-mode=loose --color",
13+
"auto-trace": "yarn turbo auto-trace --env-mode=loose --color",
1314
"build": "yarn turbo build --env-mode=loose --color",
1415
"test": "yarn turbo test --env-mode=loose --color",
1516
"start": "turbo dev --env-mode=loose --color",

packages/api/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"scripts": {
77
"dev": "serverless offline start",
88
"deploy": "serverless deploy --verbose",
9+
"auto-trace": "serverless invoke local -f main -d '{\"action\": \"auto-trace\"}'",
910
"test": "jest"
1011
},
1112
"dependencies": {

packages/api/serverless.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ functions:
121121
path: /{proxy+}
122122
method: any
123123
- schedule:
124-
rate: rate(1 day)
124+
rate: rate(2 hours)
125125
input:
126126
action: auto-trace
127127

packages/api/src/events/auto-trace.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ const updateLambda = async (lambda, arnBase, edgeEndpoint) => {
7676
},
7777
});
7878

79-
const res = await new LambdaClient().send(command);
80-
logger.info(res);
79+
await new LambdaClient().send(command);
8180
};
8281

8382
const getLambdaTags = async (lambda) => {

packages/deploy-script/src/deploy.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ import {
99
} from "@aws-sdk/client-apigatewayv2";
1010
import { checkHasUsers, createAdminUser } from "./users.js";
1111

12-
const exec = (command, options = {}) => {
12+
const exec = (command, options = {}, prefix = "") => {
1313
const child = child_process.exec(command, {
1414
...options,
1515
env: { ...process.env, ...(options.env || {}) },
1616
});
1717

1818
child.stdout?.on("data", function (data) {
19-
console.log(data?.trim());
19+
console.log(prefix + data?.trim());
2020
});
2121
child.stderr?.on("data", function (data) {
22-
console.error(data?.trim());
22+
console.error(prefix + data?.trim());
2323
});
2424

2525
return new Promise((resolve, reject) => {
@@ -85,6 +85,8 @@ const deploy = async (answers) => {
8585
console.log(chalk.blue("Deploying..."));
8686
await exec("yarn deploy", { cwd: tmpPath });
8787

88+
const endpoint = await getApiEndpoint();
89+
8890
// Create user
8991
let adminPassword;
9092
if (await checkHasUsers()) {
@@ -96,14 +98,7 @@ const deploy = async (answers) => {
9698

9799
// Run auto-trace
98100
console.log(chalk.blue("Auto tracing lambdas..."));
99-
const endpoint = await getApiEndpoint();
100-
try {
101-
await fetch(`https://${endpoint}/api/auto-trace`, {
102-
method: "POST",
103-
headers: { "Content-Type": "application/json" },
104-
body: JSON.stringify({ token: answers.tracerToken }),
105-
});
106-
} catch (e) {}
101+
await exec("yarn auto-trace", { cwd: tmpPath }, " ");
107102

108103
return { endpoint, adminPassword };
109104
};

turbo.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
"test:e2e": {
2020
"inputs": ["$TURBO_DEFAULT$", ".env*"]
2121
},
22+
"auto-trace": {
23+
"inputs": ["$TURBO_DEFAULT$", ".env*"]
24+
},
2225
"dev": {
2326
"cache": false,
2427
"persistent": true

0 commit comments

Comments
 (0)