question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Informations

Is your feature request related to a problem? Please describe. Adding an implementation of terminus library. This can be used to create a route which determine if our app is health or unhealth.

Describe the solution you’d like Add a @Health decorator based on the terminus library. Nest have his own implementation of the terminus library for example.

import { Health } from "@tsed/terminus";

@Controller("/health")
export class HealthController {
    @Health()
    public health() {
        // determine is the app is health or not
    }
}

Describe alternatives you’ve considered Currently, I have just create a simple controller and service which check if my database is up or not. This work but it does not cover all the cases covered by terminus :

HealthService.ts

import { Inject, Service } from '@tsed/di';
import { MongooseService } from '@tsed/mongoose';
import { version } from '../../package.json';

@Service()
export default class HealthService {
  @Inject(MongooseService)
  public mongoose: MongooseService;

  public health() {
    const { readyState } = this.mongoose.get();

    if (readyState === 0 || readyState === 2 || readyState === 3) {
      return Promise.reject(new Error());
    }

    return Promise.resolve({ version });
  }
}

HealthController.ts

import { Controller, Get, Inject } from '@tsed/common';
import HealthService from './HealthService';

@Controller('/health')
export default class HealthController {
  @Inject(HealthService)
  private healthService: HealthService;

  @Get()
  public async health() {
    try {
      const { version } = await this.healthService.health();
      return {
        status: 'ok',
        version,
      };
    } catch (error) {
      return { status: 'error' };
    }
  }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
yuki-takeicommented, May 25, 2021

Our implementation for graceful-shutdown with terminus. It’s not well-tested code, but I hope it helps you.

https://github.com/weseek/growi/commit/7246df4f761d5bd50f60f23fe1d48faf339e70b5

1reaction
EmilienLeroycommented, Mar 2, 2021

Thanks ! I don’t have lot of free time now but when I can, I will take a look to this feature !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Install Plugins | Terminus Guide | Pantheon Docs
Install Plugins. Terminus ships with a plugin manager. You can use a Terminus command like the example below to install a plugin: terminus...
Read more >
Terminus Plugin Project - GitHub
Terminus plugin to automate the process of updating a site through the upstream. This performs a backup before applying upstream updates.
Read more >
Terminus — QGIS Python Plugins Repository
Terminus Plugin icon ... A plugin to perform Image Segmentation. It requires the installation of Scikit-image Python library. For more information please visit ......
Read more >
pantheon-systems/terminus-plugin-example - Packagist
A simple plugin for Terminus-CLI to demonstrate how to add new commands. Adds commands 'hello' and 'auth:hello' to Terminus. Learn more about Terminus...
Read more >
Terminus - Package Control
Bring a real terminal to Sublime Text · Windows support · continuous history · easily customizable themes (see Terminus Utilities) · unicode support...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found