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

Adjust graylog entrypoint.sh with curl #187

Open
samkhamk opened this issue Nov 1, 2021 · 4 comments
Open

Adjust graylog entrypoint.sh with curl #187

samkhamk opened this issue Nov 1, 2021 · 4 comments
Assignees
Labels

Comments

@samkhamk
Copy link

samkhamk commented Nov 1, 2021

Hello Team,

I was trying to bring curl command to bring some properties enabled once graylog is up but its not working for me

I tried below thing
graylog() {

exec "${JAVA_HOME}/bin/java"
${GRAYLOG_SERVER_JAVA_OPTS}
-jar
-Dlog4j.configurationFile="${GRAYLOG_HOME}/data/config/log4j2.xml"
-Djava.library.path="${GRAYLOG_HOME}/lib/sigar/"
-Dgraylog2.installation_source=docker
"${GRAYLOG_HOME}/graylog.jar"
server
-f "${GRAYLOG_HOME}/data/config/graylog.conf"
}

curl() {
curl something
}

run() {
setup
graylog
curl
}

run

but its not working , then I tried below thing

graylog() {

exec "${JAVA_HOME}/bin/java"
${GRAYLOG_SERVER_JAVA_OPTS}
-jar
-Dlog4j.configurationFile="${GRAYLOG_HOME}/data/config/log4j2.xml"
-Djava.library.path="${GRAYLOG_HOME}/lib/sigar/"
-Dgraylog2.installation_source=docker
"${GRAYLOG_HOME}/graylog.jar"
server
-f "${GRAYLOG_HOME}/data/config/graylog.conf" &&
curl something
}

it works command gets executed but container keeps on restarting , even I tried below thing s

graylog() {

"${JAVA_HOME}/bin/java"
${GRAYLOG_SERVER_JAVA_OPTS}
-jar
-Dlog4j.configurationFile="${GRAYLOG_HOME}/data/config/log4j2.xml"
-Djava.library.path="${GRAYLOG_HOME}/lib/sigar/"
-Dgraylog2.installation_source=docker
"${GRAYLOG_HOME}/graylog.jar"
server
-f "${GRAYLOG_HOME}/data/config/graylog.conf" &&
curl something
exec "$@"
}

it is also not working, can someone help me here how I can add curl after graylog is up in automated way, I tried to get help from community but no luck,

I dont want to use any operator or sidecar for this. please help I am sorry to for asking help in this manner.

Regards,
SAM

@samkhamk samkhamk changed the title Adjust graylog entripoint.sh with curl Adjust graylog entrypoint.sh with curl Nov 1, 2021
@malcyon
Copy link

malcyon commented Nov 1, 2021

I'm not clear what your curl command is doing. Is it setting an environment variable for a Graylog property?

I think you would want to set the env vars before the java command that starts Graylog. Something like:

run() {
setup
curl
graylog
}

Or even just put your curl command into the setup function.

@samkhamk
Copy link
Author

samkhamk commented Nov 1, 2021

Hello @malcyon

I am trying below

curl -i -X PUT -u $GRAYLOGUSER:$GRAYLOGPASSWORD -H 'Content-Type: application/json' -H 'X-Requested-By: cli' 'http://graylog-core:9000/graylog/api/system/authentication/http-header-auth-config' -d '{"enabled":true,"username_header":"X-Forwarded-User"}'

which needs graylog to be up and functional, can you help me to here, I hope its clear now.

Regards,
Sam

@malcyon
Copy link

malcyon commented Nov 1, 2021

Okay. I see. I think you need to daemonize Graylog itself for what you're doing to work. In the first example, the script will stop executing commands until Graylog exits.

Not sure what's happening in the second example. It may be that Graylog is being backgrounded. And then when curl exits, the script is done, so Docker exits. Docker is really designed to run ONE command. When that command exits, the container is stopped. And then it might restart if your docker-compose is configured to do that.

@malcyon
Copy link

malcyon commented Nov 1, 2021

The problem is, if you were to daemonize Graylog, then the container would just exit. Docker is supposed to just run one command, and the container stops when that command exits. That's why all the stuff in our script runs before the java process.

If you daemonized Graylog, then ran your curl script, then had an infinite while loop in Bash after that, it might work. But then the container wouldn't stop properly.

You'll probably have to accomplish this in a different way. A sidecar is a good idea, even though you said you didn't want to do that.

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

No branches or pull requests

3 participants