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

Error on shuting down application in docker #100

Closed
Karql opened this issue Jan 6, 2025 · 1 comment
Closed

Error on shuting down application in docker #100

Karql opened this issue Jan 6, 2025 · 1 comment

Comments

@Karql
Copy link
Owner

Karql commented Jan 6, 2025

npm error path /opt/elastalert-server
npm error command failed
npm error signal SIGTERM
npm error command sh -c sh ./scripts/start.sh
npm notice
npm notice New major version of npm available! 10.9.0 -> 11.0.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.0.0
npm notice To update run: npm install -g npm@11.0.0
npm notice
npm error A complete log of this run can be found in: /home/node/.npm/_logs/2025-01-06T11_34_41_233Z-debug-0.log

> elastalert2-server@5.11.0 start
> sh ./scripts/start.sh
@Karql
Copy link
Owner Author

Karql commented Jan 6, 2025

Problem is with pipe NODE_PATH=. node dist/index.js | ./node_modules/.bin/bunyan -o short

I have tried to use tini + modify start.sh to:

#!/bin/bash
handle_signal() {
  echo "Caught signal: $1"
  # Przesyłanie sygnału do procesu Node.js
  kill -$1 $child_pid # or directly first node
}

# Zarejestrowanie obsługi sygnałów
trap 'handle_signal SIGTERM' SIGTERM
trap 'handle_signal SIGINT' SIGINT

NODE_PATH=. node dist/index.js | ./node_modules/.bin/bunyan -o short &
child_pid=$!

wait

but without success - wait does not work and script is killed before node app - only adding sleep x helps - but it is ugly...

So I've decided to remove short formating and run application without it.

Adding a short format without a separate application is more complicated: https://stackoverflow.com/questions/20880062/how-to-set-short-output-mode-in-bunyan-by-default

Additionally, the format configuration would have to be via environment variables, because the logger is used already when extracting the configuration.

If anyone needs this format please add an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant