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

Add option for shell executer #90

Closed
wants to merge 1 commit into from
Closed

Add option for shell executer #90

wants to merge 1 commit into from

Conversation

arc279
Copy link

@arc279 arc279 commented Oct 3, 2017

take over environment variables from parent process.

To need ENV from parent when mounted as rails engine.

take over environment variables from parent process.
@eisuke
Copy link
Member

eisuke commented Oct 4, 2017

@arc279 Can you please tell me the use case for this pull request? I think that it will be solved on the shell command side (i.e dotenv gem and so on)

@arc279
Copy link
Author

arc279 commented Oct 5, 2017

@eisuke

Our rails app mounts kuroko2 like this,

mount Kuroko2::Engine => '/kuroko2'

and, settings are in config/application.yml as using Figaro, but not like dotenv.

We need main app's ENV(via application.yml) for kuroko2's scripts.

@eisuke
Copy link
Member

eisuke commented Oct 5, 2017

@arc279

We need main app's ENV(via application.yml) for kuroko2's scripts.

The command-executor which executes the shell command is started by a process different from the Rails application which mounted kuroko2 engine. Therefore the mounted path does not matter.

And I think that the environment variable should be loaded on by the executed command side.
For example, if you use the rake command or rails runner in kuroko2 execute task, environment variables that configured by config/application.yml should be loaded. The Figaro gem should not be an exception.

If what I pointed out is wrong, Can I see your actual kuroko2 script?

@arc279
Copy link
Author

arc279 commented Oct 6, 2017

@eisuke

We use bricolage for aws redshift manipulations,
and kuroko2 script like this,

execute: bundle exec bricolage -e development  --job lib/bricolage/path/to.job --variable=foo=bar

but unfortunately, bricolage command can't load main app's config/application.yml.

I thought of using kuroko2's env task instead,
but abandoned for reason that secret variables expand and insert into script(like aws_secret_key).

We want to pass main app's ENV while keeping it hidden.

@eisuke
Copy link
Member

eisuke commented Oct 6, 2017

@arc279

Thank you for sharing your kuroko2 script. I understood your situation.
But I think it is not a responsibility of kuroko2 command-executor (
I think that executed process and command-executor process should be independent. Even cron and systemd do not pass all environment variables).

It seems better to wrap the bricolage command from your main rails application, Like bundle exec your_main_rails_app_path/bin/bricolage_runner.rb [options], Or
use Rails-independent environment variable management system.

@eisuke eisuke closed this Oct 6, 2017
@arc279
Copy link
Author

arc279 commented Oct 6, 2017

@eisuke

OK, we will adopt dotenv instead of Figaro in our app, and source .env before bricolage command.
Thanks for your advice.

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

Successfully merging this pull request may close these issues.

None yet

2 participants