Skip to content

In the run.sh script, why are there backticks around the startup command? #15

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

Closed
timvlaer opened this issue Feb 3, 2025 · 3 comments
Closed

Comments

@timvlaer
Copy link

timvlaer commented Feb 3, 2025

See

`python3 /usr/bin/amazon_kclpy_helper.py --print_command --java /usr/bin/java --properties /usr/bin/sample.properties --log-configuration /usr/bin/logback.xml` &

I am confused by the syntax with backticks. I thought it is an old way of writing $() to evaluate something inline and use the output in the command itself. But since this command on line 4 is not nested, I wonder what the added value is.

It also distracts from the super important & at the end which makes sure the command is ran in the background so the script continues to the tail of the log. (If you don't run it in the background, there's no logging at all.)

I understand the MultiLangDaemon uses stdin and stdout for communication with the python process. Is that the reason the python process itself cannot run as the main process?

@timvlaer
Copy link
Author

timvlaer commented Feb 3, 2025

I can confirm the backticks are required to get some logging out of the container, but my question remains, what does it so that this somehow works?

@timvlaer
Copy link
Author

timvlaer commented Feb 4, 2025

I think I get it now, the amazon_kclpy_helper script outputs the command that needs to be executed, hence the backticks.

Now, following SC2091 and SC2092, I propose to write it like this:

command=$(python3 /usr/local/lib/python3.9/site-packages/samples/amazon_kclpy_helper.py --print_command --java /usr/bin/java -p /usr/bin/record_processor.properties --log-configuration /usr/bin/logback.xml)
eval "$command" &

@timvlaer
Copy link
Author

timvlaer commented Feb 4, 2025

I opened PR #16 with these proposals included.

@timvlaer timvlaer closed this as completed Feb 4, 2025
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