-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
115 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
#!/usr/bin/ruby | ||
require 'rubygems' | ||
gem 'aws-sdk' | ||
|
||
require 'aws-sdk' | ||
require 'erb' | ||
require 'rubygems' | ||
gem 'aws-sdk' | ||
require 'aws-sdk' | ||
require 'erb' | ||
|
||
environment = ENV["RAILS_ENV"] | ||
AWS_CREDENTIALS = YAML.load(ERB.new(File.read("config/whenever-elasticbeanstalk.yml")).result)[ENV["RAILS_ENV"]] | ||
|
||
instance_id = if File.exists?("/var/app/support/instance_id") | ||
File.read("/var/app/support/instance_id") | ||
else | ||
if id = `/opt/aws/bin/ec2-metadata -i | awk '{print $2}'`.strip | ||
File.open("/var/app/support/instance_id", 'w') {|f| f.write(id) } | ||
id | ||
EB_CONFIG_APP_SUPPORT = ENV['EB_CONFIG_APP_SUPPORT'] | ||
ENVIRONMENT = ENV["RACK_ENV"] | ||
instance_id = if File.exists?(File.join(EB_CONFIG_APP_SUPPORT,'instance_id')) | ||
File.read(File.join(EB_CONFIG_APP_SUPPORT,'instance_id')) | ||
else | ||
if id = `/opt/aws/bin/ec2-metadata -i | awk '{print $2}'`.strip | ||
File.open(File.join(EB_CONFIG_APP_SUPPORT,'instance_id'), 'w') {|f| f.write(id) } | ||
id | ||
end | ||
end | ||
end | ||
availability_zone = `/opt/aws/bin/ec2-metadata -z | awk '{print $2}'`.strip | ||
region = availability_zone.slice(0..availability_zone.length-2) | ||
|
||
AWS.config(AWS_CREDENTIALS) | ||
AWS.config({:credential_provider => AWS::Core::CredentialProviders::EC2Provider.new,:region => region}) | ||
ec2 = AWS::EC2.new | ||
|
||
unless (`echo $PATH`).match("/usr/local/bin") | ||
`export PATH=/usr/local/bin:$PATH` | ||
end | ||
|
||
if ec2.instances[instance_id].tags["leader"] == "true" | ||
`bundle exec whenever --roles leader --set 'environment=#{environment}&path=/var/app/current' --update-crontab` | ||
`/usr/local/bin/bundle exec whenever --roles leader --set 'environment=#{ENVIRONMENT}&path=/var/app/current' --update-crontab` | ||
else | ||
`bundle exec whenever --roles non-leader --set 'environment=#{environment}&path=/var/app/current' --update-crontab` | ||
`/usr/local/bin/bundle exec whenever --roles non-leader --set 'environment=#{ENVIRONMENT}&path=/var/app/current' --update-crontab` | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module Whenever | ||
module Elasticbeanstalk | ||
VERSION = "1.1.3" | ||
VERSION = "1.1.4" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,15 +7,15 @@ Gem::Specification.new do |gem| | |
gem.name = "whenever-elasticbeanstalk" | ||
gem.version = Whenever::Elasticbeanstalk::VERSION | ||
gem.platform = Gem::Platform::RUBY | ||
gem.authors = ["Chad McGimpsey"] | ||
gem.email = ["[email protected]"] | ||
gem.authors = ["Chad McGimpsey","Joel Courtney"] | ||
gem.email = ["[email protected]","[email protected]"] | ||
gem.description = %q{Use Whenever on AWS Elastic Beanstalk} | ||
gem.summary = %q{Allows you to run cron jobs easily on one or all AWS Elastic Beanstalk instances.} | ||
gem.homepage = "https://github.com/dignoe/whenever-elasticbeanstalk" | ||
gem.license = 'MIT' | ||
|
||
gem.add_dependency('whenever') | ||
gem.add_dependency('aws-sdk') | ||
gem.add_dependency('whenever','~> 0.9.2') | ||
gem.add_dependency('aws-sdk', '~> 1.50.0') | ||
|
||
gem.files = `git ls-files`.split($/) | ||
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } | ||
|