Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal: Use health_status to check if server is up #767

Open
plocket opened this issue Sep 28, 2023 · 3 comments
Open

Internal: Use health_status to check if server is up #767

plocket opened this issue Sep 28, 2023 · 3 comments
Labels
bite-sized Well circumscribed small task enhancement New feature or request

Comments

@plocket
Copy link
Collaborator

plocket commented Sep 28, 2023

Use a server_url.com/health_check?ready=1 type of thing instead of making get_user_id() do double duty. That API call isn't really designed for that anyway.

@plocket plocket added enhancement New feature or request reopen We won't be taking care of this any time soon. bite-sized Well circumscribed small task labels Sep 28, 2023
@BryceStevenWilley
Copy link
Collaborator

Confirming that you mean get_dev_id, and that it would just be changed for is_server_responding, right?

let response = await _da_REST.get_dev_id( timeout );

Slight suggestion to use server_url.com/health_status?ready=1 instead, which is already in JSON. It'll look something like this:

{
  "ok": true,
  "server_start_time": 1696040337.5918229,
  "version": "1.4.67"
}

@plocket
Copy link
Collaborator Author

plocket commented Oct 7, 2023

Yes and sounds good 👍

@plocket plocket changed the title Internal: Use health_check to check if server is up Internal: Use health_status to check if server is up Oct 7, 2023
@plocket
Copy link
Collaborator Author

plocket commented Dec 3, 2023

Note: We still need get_dev_id() for the playground interview url address and we might add some setup code for playground installs to specifically check that they have given the right API key so we don't go through (potentially) reloading the server and everything before then discovering the API key is invalid.

Moving on, the code would look similar to this, just with health_status:

// node -e 'require("./lib/docassemble/docassemble_api_REST.js").health_check()'
da.health_check = async function ( timeout ) {
  try {
    return await axios.get(
      `${ session_vars.get_da_server_url() }/health_check?ready=1`,
      { timeout }
    );
  } catch ( error ) {
    let response = error.response || { data: null }
    throw { ...error.toJSON(), data: response.data };
  }
};  // Ends da.health_check()

@plocket plocket removed the reopen We won't be taking care of this any time soon. label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bite-sized Well circumscribed small task enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants