🎥 Make videos programmatically with React
can now set timeout of service when deploying
Matt McGillivrayb16111f34565
diff --git a/packages/cloudrun/src/api/check-if-service-exists.ts b/packages/cloudrun/src/api/check-if-service-exists.tsindex 9e6fe36cb8..c0e2ca26a8 100644--- a/packages/cloudrun/src/api/check-if-service-exists.ts+++ b/packages/cloudrun/src/api/check-if-service-exists.ts@@ -9,6 +9,7 @@ import {getCloudRunClient} from './helpers/get-cloud-run-client';export type CheckIfServiceExistsInput = {memoryLimit: string;cpuLimit: string;+ timeoutSeconds: number;projectID: string;region: string;};@@ -32,6 +33,7 @@ export const checkIfServiceExists = async (const serviceName = generateServiceName({memoryLimit: options.memoryLimit,cpuLimit: options.cpuLimit,+ timeoutSeconds: options.timeoutSeconds,});const cloudRunClient = getCloudRunClient();diff --git a/packages/cloudrun/src/api/deploy-service.ts b/packages/cloudrun/src/api/deploy-service.tsindex 44c61f22dc..a7f88b9596 100644--- a/packages/cloudrun/src/api/deploy-service.ts+++ b/packages/cloudrun/src/api/deploy-service.ts@@ -10,6 +10,7 @@ export type DeployServiceInput = {remotionVersion: string;memoryLimit?: string;cpuLimit?: string;+ timeoutSeconds?: number;projectID: string;region: string;};@@ -44,6 +45,10 @@ export const deployService = async (options.cpuLimit = '1.0';}+ if (!options.timeoutSeconds) {+ options.timeoutSeconds = 300;+ }+const parent = `projects/${options.projectID}/locations/${options.region}`;const cloudRunClient = getCloudRunClient();@@ -51,6 +56,7 @@ export const deployService = async (const existingService = await checkIfServiceExists({memoryLimit: options.memoryLimit,cpuLimit: options.cpuLimit,+ timeoutSeconds: options.timeoutSeconds,projectID: options.projectID,region: options.region,});@@ -58,6 +64,7 @@ export const deployService = async (const serviceName = generateServiceName({memoryLimit: options.memoryLimit,cpuLimit: options.cpuLimit,+ timeoutSeconds: options.timeoutSeconds,});if (existingService) {@@ -77,6 +84,7 @@ export const deployService = async (remotionVersion: options.remotionVersion,memoryLimit: options.memoryLimit,cpuLimit: options.cpuLimit,+ timeoutSeconds: options.timeoutSeconds,}),},serviceId: serviceName,diff --git a/packages/cloudrun/src/api/helpers/construct-service-deploy-request.ts b/packages/cloudrun/src/api/helpers/construct-service-deploy-request.tsindex 287a9523b7..f1e77d873e 100644--- a/packages/cloudrun/src/api/helpers/construct-service-deploy-request.ts+++ b/packages/cloudrun/src/api/helpers/construct-service-deploy-request.ts@@ -2,12 +2,17 @@ export const constructServiceTemplate = ({remotionVersion,memoryLimit,cpuLimit,+ timeoutSeconds,}: {remotionVersion: string;memoryLimit: string;cpuLimit: string;+ timeoutSeconds: number;}) => {return {+ timeout: {+ seconds: timeoutSeconds,+ },containers: [{image: `us-docker.pkg.dev/remotion-dev/cloud-run/render:${remotionVersion}`,diff --git a/packages/cloudrun/src/cli/commands/services/deploy.ts b/packages/cloudrun/src/cli/commands/services/deploy.tsindex 951f0ec666..c1a38666d6 100644--- a/packages/cloudrun/src/cli/commands/services/deploy.ts+++ b/packages/cloudrun/src/cli/commands/services/deploy.ts@@ -20,6 +20,7 @@ export const cloudRunDeploySubcommand = async () => {parsedCloudrunCli['allow-unauthenticated'] ?? false;let memoryLimit = parsedCloudrunCli.memoryLimit ?? '512Mi';let cpuLimit = parsedCloudrunCli.cpuLimit ?? '1.0';+ const timeoutSeconds = parsedCloudrunCli.timeoutSeconds ?? 300;memoryLimit = String(memoryLimit);cpuLimit = String(cpuLimit);@@ -33,6 +34,7 @@ Validating Deployment of Cloud Run Service:Remotion Version = ${remotionVersion}Service Memory Limit = ${memoryLimit}Service CPU Limit = ${cpuLimit}+ Service Timeout In Seconds = ${timeoutSeconds}Project Name = ${projectID}Region = ${region}Allow Unauthenticated Access = ${allowUnauthenticated}@@ -58,6 +60,7 @@ Validating Deployment of Cloud Run Service:remotionVersion,memoryLimit,cpuLimit,+ timeoutSeconds,projectID,region,});@@ -117,6 +120,7 @@ Validating Deployment of Cloud Run Service:`Failed to deploy service - ${generateServiceName({memoryLimit,cpuLimit,+ timeoutSeconds,})}.`));diff --git a/packages/cloudrun/src/cli/commands/services/ls.ts b/packages/cloudrun/src/cli/commands/services/ls.tsindex 65c0df83c2..a6ede35186 100644--- a/packages/cloudrun/src/cli/commands/services/ls.ts+++ b/packages/cloudrun/src/cli/commands/services/ls.ts@@ -1,5 +1,4 @@import {CliInternals} from '@remotion/cli';-import {getServiceInfo} from '../../../api/get-service-info';import {getServices} from '../../../api/get-services';import {getGcpRegion} from '../../get-gcp-region';@@ -19,13 +18,6 @@ export const servicesLsCommand = async () => {});fetchingOutput.update('Getting services...');- const serviceTest = await getServiceInfo({- region,- serviceName: 'remotion--3-3-82--mem512mi--cpu2-0',- });-- CliInternals.Log.info('serviceTest: ', serviceTest);-const services = await getServices({region,compatibleOnly: false,diff --git a/packages/cloudrun/src/shared/generate-service-name.ts b/packages/cloudrun/src/shared/generate-service-name.tsindex 0da061dd86..a73431a54d 100644--- a/packages/cloudrun/src/shared/generate-service-name.ts+++ b/packages/cloudrun/src/shared/generate-service-name.ts@@ -4,9 +4,11 @@ import {SERVICE_VERSION_STRING} from './service-version-string';export const generateServiceName = ({memoryLimit,cpuLimit,+ timeoutSeconds,}: {memoryLimit: string;cpuLimit: string;+ timeoutSeconds: number;}): string => {const sanitisedCPU = cpuLimit.replace(/\./g, '-').substring(0, 10);@@ -20,5 +22,6 @@ export const generateServiceName = ({SERVICE_VERSION_STRING,`mem${sanitisedMem}`,`cpu${sanitisedCPU}`,+ `t-${String(timeoutSeconds)}`,].join('--');};diff --git a/packages/docs/docs/cloudrun/deployservice.md b/packages/docs/docs/cloudrun/deployservice.mdindex ad17fdf2e1..f859d07f32 100644--- a/packages/docs/docs/cloudrun/deployservice.md+++ b/packages/docs/docs/cloudrun/deployservice.md@@ -22,6 +22,7 @@ const { shortName } = await deployService({remotionVersion: "3.3.82",memoryLimit: "2Gi",cpuLimit: "2.0",+ timeoutSeconds: 500,projectID: "my-remotion-project",region: "us-east1",});@@ -44,6 +45,10 @@ The upper bound on the amount of RAM that the Cloud Run service can consume. ByThe maximum number of CPU cores that the Cloud Run service can use to process requests.+### `timeoutSeconds`++How long the Cloud Run Service may run before it gets killed. Must be below 3600 seconds.+### `projectID`The [project ID](https://cloud.google.com/resource-manager/docs/creating-managing-projects#:~:text=to%20be%20unique.-,Project%20ID,-%3A%20A%20globally%20unique) of the GCP Project that has been configured for Remotion Cloud Run.@@ -52,11 +57,6 @@ The [project ID](https://cloud.google.com/resource-manager/docs/creating-managinThe [GCP region](/docs/cloudrun/region-selection) which you want to deploy the Cloud Run Service too.-### `timeoutInSeconds`--How long the Cloud Run Service may run before it gets killed. Must be below 900 seconds.-We recommend a timeout of 120 seconds or lower - remember, Remotion Lambda is the fastest if you render with a high concurrency. If your video takes longer to render, the concurrency should be increased rather than the timeout.-## Return valueAn object with the following values:diff --git a/packages/docs/docs/cloudrun/getServiceinfo.md b/packages/docs/docs/cloudrun/getServiceinfo.mdindex aa8123f1b8..a3ebf8a35d 100644--- a/packages/docs/docs/cloudrun/getServiceinfo.md+++ b/packages/docs/docs/cloudrun/getServiceinfo.md@@ -22,10 +22,10 @@ import { getServiceInfo } from "@remotion/cloudrun";const info = await getServiceInfo({region: "us-east1",- serviceName: "remotion--3-3-82--mem512mi--cpu1-0",+ serviceName: "remotion--3-3-82--mem512mi--cpu1-0--t-500",});-console.log(info.serviceName); // remotion--3-3-82--mem512mi--cpu1-0-console.log(info.timeoutInSeconds); // 120+console.log(info.serviceName); // remotion--3-3-82--mem512mi--cpu1-0--t-500+console.log(info.timeoutInSeconds); // 500console.log(info.memoryLimit); // 1500console.log(info.cpuLimit); // 2048console.log(info.remotionVersion); // '2021-07-14'