Skip to content

Conversation

ajarmoszuk
Copy link

This adds ability that was non-working in issue #2828, allowing for use of undocumented environment variable MC_HEALTH_EXTRA_ARGS setting.

This functionality was originally in bin/mc-health but not in autopause-fcns.sh which is used to autostop and autopause, and which was non-working when for example proxy protocol acceptance was enabled in Paper.


mc_server_listening() {
mc-monitor status --host localhost --port "$SERVER_PORT" --timeout 10s >& /dev/null
mc-monitor status "${MC_HEALTH_EXTRA_ARGS[@]}" --host localhost --port "$SERVER_PORT" --timeout 10s >& /dev/null
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea of this change is great, but I don't the think the syntax or usage is correct. Have you tested this?

MC_HELATH_EXTRA_ARGS is being used as an array type since normally it is declared in /data/.mc-health.env here

MC_HEALTH_EXTRA_ARGS=(
--use-server-list-ping
)
" > /data/.mc-health.env

however, the file .mc-health.env file doesn't seem to be getting source'd in the autopause scripts. So that needs to be added, such as this

Setting the env var MC_HEALTH_EXTRA_ARGS is not correct since env variables only have string values, not array values. So the array expansion ${MC_HEALTH_EXTRA_ARGS[@]} will not be correct.

I would suggest introducing a new env var named something like USES_PROXY_PROTOCOL that is "true" or "false". In the start-finalExec location above add a conditional on isTrue "$USES_PROXY_PROTOCOL" and add --use-proxy to MC_HEALTH_EXTRA_ARGS there.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, before making this pull request I've tested it with the --use-proxy option but that was about it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you wish I can make the changes you mentioned, but it will probably be in about 1.5 weeks time from now as I'm working on other projects at the moment.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, making those changes would be good. mc-health can also make use of that option then. I don't mind waiting for you to make that change.

BTW, MC_HEALTH_EXTRA_ARGS was purposely undocumented since it was only meant to communicate internally the start-time discovery for legacy ping protocol. So, it'll be great to document the new variable since it actually should be visible to users.

@itzg itzg linked an issue May 19, 2024 that may be closed by this pull request
@github-actions github-actions bot added the status/stale No recently activity has been seen and will be closed soon. label Jun 19, 2024
@github-actions github-actions bot closed this Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/stale No recently activity has been seen and will be closed soon.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When proxy-protocol set to true, autostop no longer working.

2 participants