bonethug 0.0.23 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +27 -9
- data/config/cnf.yml +1 -0
- data/config/deploy.rb +14 -4
- data/config/syncer.rb +52 -0
- data/lib/bonethug/cli.rb +15 -4
- data/lib/bonethug/version.rb +1 -1
- metadata +3 -2
data/README.md
CHANGED
@@ -12,11 +12,11 @@ Add this line to your application's Gemfile:
|
|
12
12
|
|
13
13
|
And then execute:
|
14
14
|
|
15
|
-
|
15
|
+
bundle
|
16
16
|
|
17
17
|
Or install it yourself as:
|
18
18
|
|
19
|
-
|
19
|
+
gem install bonethug
|
20
20
|
|
21
21
|
Usage
|
22
22
|
-----
|
@@ -33,7 +33,7 @@ Usage
|
|
33
33
|
|
34
34
|
|
35
35
|
|
36
|
-
**Add bonethug to an existing project
|
36
|
+
**Add bonethug to an existing project**
|
37
37
|
|
38
38
|
*If you just want to use the deploy / cron / backup framework*
|
39
39
|
|
@@ -65,16 +65,18 @@ argument*
|
|
65
65
|
*Uses astrails-safe to make a backup using the .bonethug/backup.rb file. Uses
|
66
66
|
the info contained in cnf.yml*
|
67
67
|
|
68
|
-
`bonethug backup {development|staging|production}`
|
68
|
+
`bonethug local-backup {development|staging|production}`
|
69
69
|
|
70
70
|
|
71
71
|
|
72
72
|
### Remote Commands
|
73
73
|
|
74
|
-
|
75
|
-
|
76
|
-
the host
|
77
|
-
|
74
|
+
Most of these are piped through mina. Mina uses SSH to send a bash script to
|
75
|
+
the remote server where it is executed. For these commands to work you need to
|
76
|
+
have the desired host already added to your known hosts file:
|
77
|
+
~/.ssh/known_hosts which means you can either connect to the host first,
|
78
|
+
manually add it or switch off the checking by adding the following to
|
79
|
+
~/.ssh/config.
|
78
80
|
|
79
81
|
|
80
82
|
|
@@ -95,7 +97,7 @@ Host *
|
|
95
97
|
|
96
98
|
|
97
99
|
|
98
|
-
**Trigger a Backup from the Remote Server**
|
100
|
+
**Trigger a Snapshot Backup from the Remote Server**
|
99
101
|
|
100
102
|
*This wraps mina and runs the backup task in the local .bonethug/deploy.rb file.
|
101
103
|
It calls astrails-safe on the remote server and using the remote
|
@@ -105,6 +107,22 @@ backup.*
|
|
105
107
|
|
106
108
|
`bonethug remote-backup {develoment|staging|production}`
|
107
109
|
|
110
|
+
|
111
|
+
|
112
|
+
**Trigger a Sync to or from the Remote Sync Location**
|
113
|
+
|
114
|
+
*This wraps mina and runs rsync on the remote server. It uses the info defined
|
115
|
+
in the local copy of config/cnf.yml under backup.rsync. If you have already set
|
116
|
+
up an ssh key with no pass on the remote server so it can talk to the sync
|
117
|
+
location then you wont need to provide a pass in the cnf.yml. this is prefereed
|
118
|
+
as it keeps the password out of the log files.*
|
119
|
+
|
120
|
+
BE CAREFUL USING SYNC-TO - if there are no files in the source location it will wipe the files from your deploy copy.
|
121
|
+
|
122
|
+
`bonethug sync-from {develoment|staging|production}`
|
123
|
+
|
124
|
+
`bonethug sync-to {develoment|staging|production}`
|
125
|
+
|
108
126
|
|
109
127
|
|
110
128
|
|
data/config/cnf.yml
CHANGED
data/config/deploy.rb
CHANGED
@@ -4,9 +4,14 @@
|
|
4
4
|
# - review directory permissions
|
5
5
|
# - passenger executes rails as the user that owns evironment.rb - if root owns it it runs as nobody
|
6
6
|
# - certain parts break if it can't find the config entries - should just check for them and skip if it can't find them
|
7
|
+
# - we run into problems if there is stuff that needs to be tracked by git in the vendor dirs
|
8
|
+
# -> if we add vendor to the shared paths stuff doesn't get updated properly
|
9
|
+
# -> if we dont it means that composer downloads stuff every deployment
|
10
|
+
# -> looks like composer breaks if we use symlniked paths
|
7
11
|
|
8
12
|
# Requires
|
9
13
|
# ---------------------------------------------------------------
|
14
|
+
|
10
15
|
require 'rubygems'
|
11
16
|
require 'bonethug/conf'
|
12
17
|
require 'mina/bundler'
|
@@ -30,7 +35,7 @@ raise 'could not find deployment environment' unless conf.get('deploy.environmen
|
|
30
35
|
deploy = conf.node_merge('deploy.common','deploy.environments.'+env)
|
31
36
|
resources = conf.get('resources','Array') || []
|
32
37
|
log_dirs = conf.get('log_dirs','Array') || []
|
33
|
-
|
38
|
+
vendor = conf.get('vendor','Array') || []
|
34
39
|
|
35
40
|
# vhost name
|
36
41
|
vhost = deploy.get('project_slug') + '_' + env
|
@@ -46,10 +51,11 @@ resources += ['backups']
|
|
46
51
|
log_dirs.push 'log' unless log_dirs.include? 'log'
|
47
52
|
|
48
53
|
# shared paths
|
49
|
-
shared = resources + log_dirs +
|
54
|
+
shared = resources + log_dirs + vendor + ['tmp']
|
50
55
|
shared.push 'composer.phar' if use_composer
|
51
56
|
|
52
57
|
# shared config
|
58
|
+
set :keep, deploy.get('keep') || 2
|
53
59
|
set :deploy_to, deploy.get('base_dir') + '/' + vhost
|
54
60
|
set :repository, deploy.get('repository')
|
55
61
|
set :branch, ENV['branch'] || deploy.get('default_branch')
|
@@ -72,7 +78,7 @@ desc "Sets up the Project"
|
|
72
78
|
task :setup => :environment do
|
73
79
|
|
74
80
|
# make shared resource dirs
|
75
|
-
(resources + log_dirs +
|
81
|
+
(resources + log_dirs + vendor).each do |path|
|
76
82
|
queue! %[mkdir -p "#{deploy_to}/shared/#{path}"]
|
77
83
|
end
|
78
84
|
|
@@ -126,12 +132,14 @@ end
|
|
126
132
|
|
127
133
|
desc "Syncs files to a location"
|
128
134
|
task :sync_from => :environment do
|
129
|
-
if rsync = conf.get('backup.rsync')
|
135
|
+
if rsync = conf.get('backup.rsync')
|
130
136
|
path = deploy.get('project_slug') + "_" + env + "_sync"
|
131
137
|
ssh_pass = rsync.get('pass') ? "sshpass -p #{rsync.get('pass')}" : ""
|
132
138
|
queue! %[#{ssh_pass} ssh #{rsync.get('user')}@#{rsync.get('host')} mkdir -p #{path}]
|
133
139
|
(resources + log_dirs).each do |item|
|
140
|
+
|
134
141
|
queue! %[cd #{deploy_to}/current && rsync -r -a -v -e "#{ssh_pass} ssh -l #{rsync.get('user')}" --delete --copy-dirlinks ./#{item} #{rsync.get('host')}:#{path}/]
|
142
|
+
|
135
143
|
end
|
136
144
|
else
|
137
145
|
raise 'no rsync conf'
|
@@ -145,7 +153,9 @@ task :sync_to => :environment do
|
|
145
153
|
ssh_pass = rsync.get('pass') ? "sshpass -p #{rsync.get('pass')}" : ""
|
146
154
|
queue! %[#{ssh_pass} ssh #{rsync.get('user')}@#{rsync.get('host')} mkdir -p #{path}]
|
147
155
|
(resources + log_dirs).each do |item|
|
156
|
+
|
148
157
|
queue! %[cd #{deploy_to}/current && rsync -r -a -v -e "#{ssh_pass} ssh -l #{rsync.get('user')}" --delete --copy-dirlinks #{rsync.get('host')}:#{path}/#{item} ./]
|
158
|
+
|
149
159
|
end
|
150
160
|
else
|
151
161
|
raise 'no rsync conf'
|
data/config/syncer.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Requires
|
4
|
+
# ---------------------------------------------------------------
|
5
|
+
require 'rubygems'
|
6
|
+
require 'bonethug/conf'
|
7
|
+
|
8
|
+
# Config
|
9
|
+
# ---------------------------------------------------------------
|
10
|
+
|
11
|
+
# load the conf
|
12
|
+
conf = Bonethug::Conf.new
|
13
|
+
cnf = conf.to_hash
|
14
|
+
|
15
|
+
# args
|
16
|
+
env = ARGV[1]
|
17
|
+
type = ARGV[0]
|
18
|
+
|
19
|
+
# pull config from environment vars
|
20
|
+
raise 'could not find deployment environment' unless conf.get('deploy.environments').has_key? env
|
21
|
+
|
22
|
+
# build config
|
23
|
+
deploy = conf.node_merge('deploy.common','deploy.environments.'+env)
|
24
|
+
resources = conf.get('resources','Array') || []
|
25
|
+
log_dirs = conf.get('log_dirs','Array') || []
|
26
|
+
vendor = conf.get('vendor','Array') || []
|
27
|
+
|
28
|
+
# vhost name
|
29
|
+
vhost = deploy.get('project_slug') + '_' + env
|
30
|
+
|
31
|
+
# composer?
|
32
|
+
use_composer = ['silverstripe','silverstripe3','drupal','php'].include? deploy.get('project_type')
|
33
|
+
|
34
|
+
# directories we need to track
|
35
|
+
resources += ['backups']
|
36
|
+
|
37
|
+
# logs
|
38
|
+
log_dirs.push 'log' unless log_dirs.include? 'log'
|
39
|
+
|
40
|
+
# do the common work
|
41
|
+
path = deploy.get('base_dir') + '/' + vhost
|
42
|
+
ssh_pass = rsync.get('pass') ? "sshpass -p #{rsync.get('pass')}" : ""
|
43
|
+
queue! %[#{ssh_pass} ssh #{rsync.get('user')}@#{rsync.get('host')} mkdir -p #{path}]
|
44
|
+
|
45
|
+
(resources + log_dirs).each do |item|
|
46
|
+
case type
|
47
|
+
when "sync-local-from"
|
48
|
+
exec "rsync -r -a -v -e \"#{ssh_pass} ssh -l #{rsync.get('user')}\" --delete --copy-dirlinks #{rsync.get('host')}:#{path}/current/#{item} ./"
|
49
|
+
when "sync-local-to"
|
50
|
+
exec "rsync -r -a -v -e \"#{ssh_pass} ssh -l #{rsync.get('user')}\" --delete --copy-dirlinks ./#{item} #{rsync.get('host')}:#{path}/current/"
|
51
|
+
end
|
52
|
+
end
|
data/lib/bonethug/cli.rb
CHANGED
@@ -41,7 +41,7 @@ module Bonethug
|
|
41
41
|
# run the initaliser
|
42
42
|
Installer.bonethugise(location, task.to_sym)
|
43
43
|
|
44
|
-
when 'deploy', 'setup', 'remote-backup', 'local-backup', 'sync-to', 'sync-from'
|
44
|
+
when 'deploy', 'setup', 'remote-backup', 'local-backup', 'sync-backup-to', 'sync-backup-from', 'sync-local-to', 'sync-local-from'
|
45
45
|
|
46
46
|
# handle args
|
47
47
|
environment = ARGV[1]
|
@@ -53,18 +53,29 @@ module Bonethug
|
|
53
53
|
end
|
54
54
|
|
55
55
|
case task
|
56
|
+
|
57
|
+
# Setup and Deploy
|
56
58
|
when 'deploy'
|
57
59
|
exec "export to=#{environment} && bundle exec mina -f .bonethug/deploy.rb deploy --verbose"
|
58
60
|
when 'setup'
|
59
61
|
exec "export to=#{environment} && bundle exec mina -f .bonethug/deploy.rb setup --verbose"
|
62
|
+
|
63
|
+
# Snapshot Backup
|
60
64
|
when 'remote-backup'
|
61
65
|
exec "export to=#{environment} && bundle exec mina -f .bonethug/deploy.rb backup --verbose"
|
62
66
|
when 'local-backup'
|
63
67
|
exec "export to=#{environment} && bundle exec astrails-safe .bonethug/backup.rb"
|
64
|
-
|
68
|
+
|
69
|
+
# Synchronised backup
|
70
|
+
when 'sync-backup-to'
|
65
71
|
exec "export to=#{environment} && bundle exec mina -f .bonethug/deploy.rb sync_to --verbose"
|
66
|
-
when 'sync-from'
|
67
|
-
exec "export to=#{environment} && bundle exec mina -f .bonethug/deploy.rb sync_from --verbose"
|
72
|
+
when 'sync-backup-from'
|
73
|
+
exec "export to=#{environment} && bundle exec mina -f .bonethug/deploy.rb sync_from --verbose"
|
74
|
+
|
75
|
+
when 'sync-local-to'
|
76
|
+
exec "ruby .bonethug/syncer.rb sync_local_to #{environment}"
|
77
|
+
when 'sync-local-from'
|
78
|
+
exec "ruby .bonethug/syncer.rb sync_local_from #{environment}"
|
68
79
|
end
|
69
80
|
|
70
81
|
when 'watch'
|
data/lib/bonethug/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bonethug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.24
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -287,6 +287,7 @@ files:
|
|
287
287
|
- config/cnf.yml
|
288
288
|
- config/deploy.rb
|
289
289
|
- config/schedule.rb
|
290
|
+
- config/syncer.rb
|
290
291
|
- lib/bonethug.rb
|
291
292
|
- lib/bonethug/cli.rb
|
292
293
|
- lib/bonethug/conf.rb
|