Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
James White committed Nov 27, 2016
2 parents 335dda8 + a2817ab commit 8e202b0
Show file tree
Hide file tree
Showing 16 changed files with 36 additions and 18 deletions.
2 changes: 2 additions & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
2.2.2

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ instead.

1. First check you meet the [requirements](#requirements)

2. Use the handy [install script](install.sh) or [grab the latest](https://github.com/jamesrwhite/minicron/releases/tag/v0.9.6) zip/tarball
2. Use the handy [install script](install.sh) or [grab the latest](https://github.com/jamesrwhite/minicron/releases/tag/v0.9.7) zip/tarball
for your OS and install manually.
```
bash -c "$(curl -sSL https://raw.githubusercontent.com/jamesrwhite/minicron/master/install.sh)"
Expand Down Expand Up @@ -141,8 +141,8 @@ instead.
You can also run minicron in a docker container, see below for instructions how:
````bash
docker pull jamesrwhite/minicron:v0.9.6
minicron_container_id=$(docker run -d -p 127.0.0.1:9292:9292 -i -t jamesrwhite/minicron:v0.9.6)
docker pull jamesrwhite/minicron:v0.9.7
minicron_container_id=$(docker run -d -p 127.0.0.1:9292:9292 -i -t jamesrwhite/minicron:v0.9.7)
docker exec $minicron_container_id minicron db setup
docker exec $minicron_container_id minicron server start
````
Expand Down
6 changes: 3 additions & 3 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ VAGRANTFILE_API_VERSION = "2"
$script = <<SCRIPT
apt-get update
apt-get install -y libsqlite3-dev wget unzip
wget https://github.com/jamesrwhite/minicron/releases/download/v0.9.6/minicron-0.9.6-linux-x86_64.zip > minicron.zip
unzip -o minicron-0.9.6-linux-x86_64.zip
export PATH=~/minicron-0.9.6-linux-x86_64:$PATH
wget https://github.com/jamesrwhite/minicron/releases/download/v0.9.7/minicron-0.9.7-linux-x86_64.zip > minicron.zip
unzip -o minicron-0.9.7-linux-x86_64.zip
export PATH=~/minicron-0.9.7-linux-x86_64:$PATH
ufw allow 2222
ufw allow 9292
ufw enable
Expand Down
2 changes: 2 additions & 0 deletions config/minicron.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ debug = false # Useful for debugging
[client.server]
scheme = "http" # [http, https]
host = "127.0.0.1"
# username = "username" # optional for basic auth
# password = "password" # optional for basic auth
port = 9292
path = "/"
connect_timeout = 5
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
set -e

VERSION="0.9.6"
VERSION="0.9.7"

echo "Installing mincron v$VERSION"

Expand Down
2 changes: 2 additions & 0 deletions lib/minicron.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class ClientError < Error; end
'server' => {
'scheme' => 'http',
'host' => '0.0.0.0',
'username' => nil,
'password' => nil,
'port' => 9292,
'path' => '/',
'connect_timeout' => 5,
Expand Down
2 changes: 2 additions & 0 deletions lib/minicron/cli/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ def self.add_run_cli_command(cli)
client = Minicron::Transport::Client.new(
Minicron.config['client']['server']['scheme'],
Minicron.config['client']['server']['host'],
Minicron.config['client']['server']['username'],
Minicron.config['client']['server']['password'],
Minicron.config['client']['server']['port'],
Minicron.config['client']['server']['path']
)
Expand Down
2 changes: 1 addition & 1 deletion lib/minicron/constants.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# The minicron module
module Minicron
BINARY_NAME = 'minicron'
VERSION = '0.9.6'
VERSION = '0.9.7'
DEFAULT_CONFIG_FILE = '/etc/minicron.toml'
BASE_PATH = File.expand_path('../../../', __FILE__)
DB_PATH = "#{BASE_PATH}/db"
Expand Down
4 changes: 2 additions & 2 deletions lib/minicron/hub/models/execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module Minicron
module Hub
class Execution < ActiveRecord::Base
belongs_to :job
has_many :job_execution_outputs, :dependent => :delete_all
has_many :alerts, :dependent => :delete_all
has_many :job_execution_outputs, :dependent => :destroy
has_many :alerts, :dependent => :destroy

validates :job_id, :presence => true, :numericality => { :only_integer => true }
validates :number, :presence => true, :numericality => { :only_integer => true }
Expand Down
2 changes: 1 addition & 1 deletion lib/minicron/hub/models/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Minicron
module Hub
class Host < ActiveRecord::Base
has_many :jobs, :dependent => :delete_all
has_many :jobs, :dependent => :destroy

validates :name, :presence => true
validates :fqdn, :presence => true, :uniqueness => true
Expand Down
4 changes: 2 additions & 2 deletions lib/minicron/hub/models/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ module Minicron
module Hub
class Job < ActiveRecord::Base
belongs_to :host
has_many :executions, :dependent => :delete_all
has_many :schedules, :dependent => :delete_all
has_many :executions, :dependent => :destroy
has_many :schedules, :dependent => :destroy

validates :name, :presence => true, :uniqueness => true
validates :command, :presence => true
Expand Down
2 changes: 1 addition & 1 deletion lib/minicron/hub/models/schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Minicron
module Hub
class Schedule < ActiveRecord::Base
belongs_to :job
has_many :alerts, :dependent => :delete_all
has_many :alerts, :dependent => :destroy

validates :job_id, :presence => true, :numericality => { :only_integer => true }

Expand Down
2 changes: 1 addition & 1 deletion lib/minicron/hub/views/jobs/edit.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div class="form-group">
<label class="col-sm-2 control-label">Command</label>
<div class="col-sm-10">
<input name="command" type="text" value="<%= @job[:command] %>" class="form-control" placehoder="What command should the job run"/>
<textarea name="command" rows="6" class="form-control" placeholder="What command should the job run"><%= @job[:command] %></textarea>
</div>
</div>
<div class="form-group">
Expand Down
12 changes: 10 additions & 2 deletions lib/minicron/transport/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ module Transport
class Client
# Instantiate a new instance of the client
#
# @param host [String] The host to be communicated with
def initialize(scheme, host, port, path)
# @param scheme [String] The protocol to use e.g http/https
# @param host [String] The host to be communicated with e.g test.com or 127.0.0.1
# @param username [String] The http basic auth username
# @param password [String] The http basic auth password
# @param port [Integer]
# @param path [String] Path to the minicron server e.g /minicron
def initialize(scheme, host, username, password, port, path)
@scheme = scheme
@host = host
@username = username
@password = password
@path = path == '/' ? '/api/v1' : "#{path}/api/v1"
@port = port
@seq = 1
Expand Down Expand Up @@ -148,6 +155,7 @@ def post(method, data)
# Create a POST requests
uri = URI("#{@scheme}://#{@host}:#{@port}#{@path}#{method}")
post = Net::HTTP::Post.new(uri.path)
post.basic_auth @username, @password if @username || @password
post.set_form_data(data)

# Execute the POST request, TODO: error handling
Expand Down
2 changes: 1 addition & 1 deletion minicron.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)

VERSION = "0.9.6.#{Time.now.to_i}"
VERSION = "0.9.7.#{Time.now.to_i}"

Gem::Specification.new do |spec|
spec.name = 'minicron'
Expand Down
2 changes: 2 additions & 0 deletions spec/valid_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ debug = false
[client.server]
scheme = "http" # [http, https]
host = "127.0.0.1"
# username = "username" # optional for basic auth
# password = "password" # optional for basic auth
port = 9292
path = "/"
connect_timeout = 5
Expand Down

0 comments on commit 8e202b0

Please sign in to comment.