Skip to content

Commit

Permalink
Merge pull request #19 from tungv/release/v0.3.1
Browse files Browse the repository at this point in the history
chore: add logging for CLI
  • Loading branch information
votrungquan1999 authored Jul 13, 2024
2 parents 05ba90a + d5d689a commit 862c3c1
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/jerni/jsr.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jerni/jerni-3",
"version": "0.3.0",
"version": "0.3.1",
"exports": {
".": "./src/createJourney.ts",
"./types": "./src/lib/exported_types.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/jerni/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@jerni/jerni-3",
"version": "v0.3.0",
"version": "v0.3.1",
"type": "module",
"main": "src/index.ts",
"bin": {
Expand Down
6 changes: 6 additions & 0 deletions packages/jerni/scripts/download-binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,17 @@ const download = (dest) =>
new Promise((resolve, reject) => {
// check if the file exists
if (fs.existsSync(dest)) {
console.log("Binary already exists");

return resolve();
}

// read the version from jsr.json relative to this script using `fs`
const JsrJson = fs.readFileSync(_resolve(__dirname, "../jsr.json"), "utf-8");
const { version } = JSON.parse(JsrJson);

console.log(`Downloading Binary v${version} for ${os} ${currentArch}`);

const url = `https://github.com/tungv/jerni-3/releases/download/v${version}/mycli-${suffix}`;

const file = fs.createWriteStream(dest);
Expand All @@ -54,6 +58,8 @@ const download = (dest) =>
if (response.statusCode === 200) {
response.pipe(file);
file.on("finish", () => {
console.log("Download completed");

file.close(resolve);
});

Expand Down
3 changes: 3 additions & 0 deletions packages/jerni/src/events-storage/injectDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ export interface EventDatabase {

async function getDB() {
if (process.env.EVENTS_DB_MONGODB_URL && process.env.EVENTS_DB_MONGODB_NAME) {
console.log("Using MongoDB as event storage");

return getMongodbDatabase({
url: process.env.EVENTS_DB_MONGODB_URL,
dbName: process.env.EVENTS_DB_MONGODB_NAME,
});
}

console.log("Using SQLite as event storage");
return getSqliteDb();
}

Expand Down
10 changes: 5 additions & 5 deletions packages/jerni/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ export default async function initWorker(filePath: string | undefined, port: num

const ctrl = new AbortController();

// call server.stop when process is killed
process.on("SIGINT", () => {
ctrl.abort();
});

const job: Job = {
async start() {
startHealthCheckServer(port, ctrl.signal);
Expand Down Expand Up @@ -89,9 +94,4 @@ async function startHealthCheckServer(port: number, signal: AbortSignal) {
once: true,
},
);

// call server.stop when process is killed
process.on("SIGINT", () => {
server.stop(closeAllActiveConnections);
});
}

0 comments on commit 862c3c1

Please sign in to comment.