添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Hi Render Community,

I have deployed a NodeJS/Express web service on Render and I am trying to implement a /healthcheck endpoint which also pulls the latest git version and commit timestamp using the following commands, but it is not working in Render. Although, it works successfully in my local environment.

try {
  revision = require("child_process")
    .execSync("git rev-parse --short HEAD")
    .toString()
    .trim();
} catch (error) {
  logger.error(error);
  revision = process.env.RENDER_GIT_COMMIT;

The above code results in the following output in Render logs

fatal: not a git repository (or any of the parent directories): .git
ERROR [2024-04-18 00:48:34] (57) Error: Command failed: git rev-parse --short HEAD

What am I missing here?

Hi there,

Is your service a Docker service? If so unless you copy the .git directory to your image, you will not have a Git repo within in your service. Is there any reason you don’t just use RENDER_GIT_COMMIT?

Regards,

Keith
Render Support, UTC+10 :australia:

Yes, thanks. I have already used RENDER_GIT_COMMIT in my original code above as a part of the fallback mechanism.

However, is there an attribute such as RENDER_GIT_COMMIT_TIMESTAMP, which is essentially a timestamp showing me when the last commit occurred?

Hi there,

I’m sorry but no, there isn’t an environment for you to know the date of the commit.

Regards,

Keith
Render Support, UTC+10 :australia: