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 to export env variables to daemon #119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/pleaserun/platform/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ class InvalidTemplate < ::StandardError; end
end
end

attribute :export_variables, "Env variable names to export to the daemon", :multivalued => true do
munge do |export_variables|
if export_variables.is_a?(String)
export_variables = [export_variables]
end
export_variables
end
validate do |export_variables|
insist { export_variables }.is_a?(Array)
end
end

attribute :nice, "The nice level to add to this program before running" do
validate do |nice|
insist { nice }.is_a?(Fixnum)
Expand Down
4 changes: 4 additions & 0 deletions templates/sysv/default/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ KILL_ON_STOP_TIMEOUT=0
[ -r {{{default_file}}} ] && . {{{default_file}}}
[ -r {{{sysconfig_file}}} ] && . {{{sysconfig_file}}}

{{#export_variables}}
export {{{.}}}
{{/export_variables}}

[ -z "$nice" ] && nice=0

trace() {
Expand Down