@dbos-inc/dbos-sdk 0.8.26-preview → 0.8.28-preview
Sign up to get free protection for your applications and to get access to all the features.
package/README.md
CHANGED
@@ -27,4 +27,4 @@ Our documentation has the following sections:
|
|
27
27
|
|
28
28
|
## Community
|
29
29
|
|
30
|
-
Please join our community on [Discord](https://discord.gg/
|
30
|
+
Please join our community on [Discord](https://discord.gg/fMwQjeW5zg)! If you see a bug or have a feature request, don't hesitate to open an issue here on GitHub.
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"deploy-app-code.d.ts","sourceRoot":"","sources":["../../../../src/cloud-cli/applications/deploy-app-code.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"deploy-app-code.d.ts","sourceRoot":"","sources":["../../../../src/cloud-cli/applications/deploy-app-code.ts"],"names":[],"mappings":"AAeA,wBAAsB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA6EjE"}
|
@@ -5,13 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.deployAppCode = void 0;
|
7
7
|
const axios_1 = __importDefault(require("axios"));
|
8
|
-
const yaml_1 = __importDefault(require("yaml"));
|
9
8
|
const child_process_1 = require("child_process");
|
10
|
-
const fs_1 = __importDefault(require("fs"));
|
11
9
|
const logs_1 = require("../../telemetry/logs");
|
12
10
|
const utils_1 = require("../utils");
|
13
11
|
const utils_2 = require("../../utils");
|
14
|
-
const config_1 = require("../../dbos-runtime/config");
|
15
12
|
const path_1 = __importDefault(require("path"));
|
16
13
|
const deployDirectoryName = "dbos_deploy";
|
17
14
|
async function deployAppCode(host) {
|
@@ -22,33 +19,15 @@ async function deployAppCode(host) {
|
|
22
19
|
const packageJson = require(path_1.default.join(process.cwd(), 'package.json'));
|
23
20
|
const appName = packageJson.name;
|
24
21
|
logger.info(`Loaded application name from package.json: ${appName}`);
|
25
|
-
logger.info(`
|
22
|
+
logger.info(`Submitting deploy request for ${appName}`);
|
26
23
|
try {
|
27
24
|
(0, utils_2.createDirectory)(deployDirectoryName);
|
28
|
-
|
29
|
-
if (!configFile) {
|
30
|
-
logger.error(`failed to parse ${config_1.dbosConfigFilePath}`);
|
31
|
-
return 1;
|
32
|
-
}
|
33
|
-
// Inject OTel export configuration
|
34
|
-
if (!configFile.telemetry) {
|
35
|
-
configFile.telemetry = {};
|
36
|
-
}
|
37
|
-
configFile.telemetry.OTLPExporter = {
|
38
|
-
logsEndpoint: "http://otel-collector:4318/v1/logs",
|
39
|
-
tracesEndpoint: "http://otel-collector:4318/v1/traces",
|
40
|
-
};
|
41
|
-
try {
|
42
|
-
fs_1.default.writeFileSync(`${deployDirectoryName}/${config_1.dbosConfigFilePath}`, yaml_1.default.stringify(configFile));
|
43
|
-
}
|
44
|
-
catch (e) {
|
45
|
-
logger.error(`failed to write ${config_1.dbosConfigFilePath}: ${e.message}`);
|
46
|
-
return 1;
|
47
|
-
}
|
25
|
+
// Prune unnecessary dependencies
|
48
26
|
(0, child_process_1.execSync)(`npm prune --omit=dev node_modules/* `);
|
49
|
-
|
50
|
-
(0, child_process_1.execSync)(`zip -
|
27
|
+
// Package the application into a .zip file
|
28
|
+
(0, child_process_1.execSync)(`zip -ry ${deployDirectoryName}/${appName}.zip ./* -x ${deployDirectoryName}/* > /dev/null`);
|
51
29
|
const zipData = (0, utils_2.readFileSync)(`${deployDirectoryName}/${appName}.zip`, "base64");
|
30
|
+
// Submit the deploy request
|
52
31
|
const response = await axios_1.default.post(`https://${host}/${userCredentials.userName}/application/${appName}`, {
|
53
32
|
application_archive: zipData,
|
54
33
|
}, {
|
@@ -58,7 +37,33 @@ async function deployAppCode(host) {
|
|
58
37
|
},
|
59
38
|
});
|
60
39
|
const deployOutput = response.data;
|
61
|
-
logger.info(`
|
40
|
+
logger.info(`Submitted deploy request for ${appName}. Assigned version: ${deployOutput.ApplicationVersion}`);
|
41
|
+
// Wait for the application to become available
|
42
|
+
let count = 0;
|
43
|
+
let applicationAvailable = false;
|
44
|
+
while (!applicationAvailable) {
|
45
|
+
count += 1;
|
46
|
+
if (count % 5 === 0) {
|
47
|
+
logger.info(`Waiting for ${appName} with version ${deployOutput.ApplicationVersion} to be available`);
|
48
|
+
if (count > 20) {
|
49
|
+
logger.info(`If ${appName} takes too long to become available, check its logs at...`);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
// Retrieve the application status, check if it is "AVAILABLE"
|
53
|
+
const list = await axios_1.default.get(`https://${host}/${userCredentials.userName}/application`, {
|
54
|
+
headers: {
|
55
|
+
Authorization: bearerToken,
|
56
|
+
},
|
57
|
+
});
|
58
|
+
const applications = list.data;
|
59
|
+
for (const application of applications) {
|
60
|
+
if (application.Name === appName && application.Status === "AVAILABLE") {
|
61
|
+
applicationAvailable = true;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
await (0, utils_2.sleep)(1000);
|
65
|
+
}
|
66
|
+
logger.info(`Application ${appName} successfuly deployed`);
|
62
67
|
logger.info(`Access your application at https://${host}/${userCredentials.userName}/application/${appName}`);
|
63
68
|
return 0;
|
64
69
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"deploy-app-code.js","sourceRoot":"","sources":["../../../../src/cloud-cli/applications/deploy-app-code.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,
|
1
|
+
{"version":3,"file":"deploy-app-code.js","sourceRoot":"","sources":["../../../../src/cloud-cli/applications/deploy-app-code.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,iDAAyC;AACzC,+CAAoD;AACpD,oCAA+C;AAC/C,uCAAmE;AACnE,gDAAwB;AAGxB,MAAM,mBAAmB,GAAG,aAAa,CAAC;AAOnC,KAAK,UAAU,aAAa,CAAC,IAAY;IAC9C,MAAM,MAAM,GAAG,IAAI,mBAAY,EAAE,CAAC;IAClC,MAAM,eAAe,GAAG,IAAA,2BAAmB,GAAE,CAAC;IAC9C,MAAM,WAAW,GAAG,SAAS,GAAG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