sunshine 1.0.0.pre

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.
Files changed (71) hide show
  1. data/History.txt +237 -0
  2. data/Manifest.txt +70 -0
  3. data/README.txt +277 -0
  4. data/Rakefile +46 -0
  5. data/bin/sunshine +5 -0
  6. data/examples/deploy.rb +61 -0
  7. data/examples/deploy_tasks.rake +112 -0
  8. data/examples/standalone_deploy.rb +31 -0
  9. data/lib/commands/add.rb +96 -0
  10. data/lib/commands/default.rb +169 -0
  11. data/lib/commands/list.rb +322 -0
  12. data/lib/commands/restart.rb +62 -0
  13. data/lib/commands/rm.rb +83 -0
  14. data/lib/commands/run.rb +151 -0
  15. data/lib/commands/start.rb +72 -0
  16. data/lib/commands/stop.rb +61 -0
  17. data/lib/sunshine/app.rb +876 -0
  18. data/lib/sunshine/binder.rb +70 -0
  19. data/lib/sunshine/crontab.rb +143 -0
  20. data/lib/sunshine/daemon.rb +380 -0
  21. data/lib/sunshine/daemons/ar_sendmail.rb +28 -0
  22. data/lib/sunshine/daemons/delayed_job.rb +30 -0
  23. data/lib/sunshine/daemons/nginx.rb +104 -0
  24. data/lib/sunshine/daemons/rainbows.rb +35 -0
  25. data/lib/sunshine/daemons/server.rb +66 -0
  26. data/lib/sunshine/daemons/unicorn.rb +26 -0
  27. data/lib/sunshine/dependencies.rb +103 -0
  28. data/lib/sunshine/dependency_lib.rb +200 -0
  29. data/lib/sunshine/exceptions.rb +54 -0
  30. data/lib/sunshine/healthcheck.rb +83 -0
  31. data/lib/sunshine/output.rb +131 -0
  32. data/lib/sunshine/package_managers/apt.rb +48 -0
  33. data/lib/sunshine/package_managers/dependency.rb +349 -0
  34. data/lib/sunshine/package_managers/gem.rb +54 -0
  35. data/lib/sunshine/package_managers/yum.rb +62 -0
  36. data/lib/sunshine/remote_shell.rb +241 -0
  37. data/lib/sunshine/repo.rb +128 -0
  38. data/lib/sunshine/repos/git_repo.rb +122 -0
  39. data/lib/sunshine/repos/rsync_repo.rb +29 -0
  40. data/lib/sunshine/repos/svn_repo.rb +78 -0
  41. data/lib/sunshine/server_app.rb +554 -0
  42. data/lib/sunshine/shell.rb +384 -0
  43. data/lib/sunshine.rb +391 -0
  44. data/templates/logrotate/logrotate.conf.erb +11 -0
  45. data/templates/nginx/nginx.conf.erb +109 -0
  46. data/templates/nginx/nginx_optimize.conf +23 -0
  47. data/templates/nginx/nginx_proxy.conf +13 -0
  48. data/templates/rainbows/rainbows.conf.erb +18 -0
  49. data/templates/tasks/sunshine.rake +114 -0
  50. data/templates/unicorn/unicorn.conf.erb +6 -0
  51. data/test/fixtures/app_configs/test_app.yml +11 -0
  52. data/test/fixtures/sunshine_test/test_upload +0 -0
  53. data/test/mocks/mock_object.rb +179 -0
  54. data/test/mocks/mock_open4.rb +117 -0
  55. data/test/test_helper.rb +188 -0
  56. data/test/unit/test_app.rb +489 -0
  57. data/test/unit/test_binder.rb +20 -0
  58. data/test/unit/test_crontab.rb +128 -0
  59. data/test/unit/test_git_repo.rb +26 -0
  60. data/test/unit/test_healthcheck.rb +70 -0
  61. data/test/unit/test_nginx.rb +107 -0
  62. data/test/unit/test_rainbows.rb +26 -0
  63. data/test/unit/test_remote_shell.rb +102 -0
  64. data/test/unit/test_repo.rb +42 -0
  65. data/test/unit/test_server.rb +324 -0
  66. data/test/unit/test_server_app.rb +425 -0
  67. data/test/unit/test_shell.rb +97 -0
  68. data/test/unit/test_sunshine.rb +157 -0
  69. data/test/unit/test_svn_repo.rb +55 -0
  70. data/test/unit/test_unicorn.rb +22 -0
  71. metadata +217 -0
data/History.txt ADDED
@@ -0,0 +1,237 @@
1
+ === 1.0.0 / 2010-03-26
2
+
3
+ * Improvements:
4
+
5
+ * Removed all Atti-specific code for public release.
6
+
7
+ * Bugfixes:
8
+
9
+ * Fixed Nginx passenger implementation.
10
+
11
+
12
+ === 0.0.6 / 2010-03-19
13
+
14
+ * Major:
15
+
16
+ * Removed DeployServerDispatcher. Dispatching now happens at the App level.
17
+
18
+ * Moved Settler into Sunshine and renamed it to DependencyLib.
19
+
20
+ * Improvements:
21
+
22
+ * Added INT signal handling to exit deploys and close connections gracefully.
23
+
24
+ * Added dependency installation methods apt_install, gem_install,
25
+ tpkg_install and yum_install to App and ServerApp.
26
+
27
+ * Extended functionality of ServerApp#upload_tasks.
28
+
29
+ * ServerApp now support being instatiated with an App instance (for
30
+ coordinated deploys) or just with an app name (for post-deploy usage).
31
+
32
+ * Added a Sunshine rakefile template for task-based deploys.
33
+ Available through: sunshine --rakefile [COPY_TO]
34
+
35
+ * App#name gets auto-assigned by repo info if not provided.
36
+
37
+ * Sunshine::web_directory used to determine App#deploy_path when missing.
38
+
39
+ * Repo#detect now returns a Repo object instead of an array.
40
+
41
+ * Added start/stop/restart/status methods to DeployServerApp.
42
+
43
+ * ServerApp instances with unspecified roles get all roles by default.
44
+
45
+ * App config files now use erb parsing.
46
+ Any key/value passed the App constructor as a hash should be passed
47
+ to the erb binding along with the deploy_env.
48
+
49
+ * Added support to bundler for defining multiple dependencies with the same
50
+ name, and different package managers.
51
+
52
+ * Bugfixes:
53
+
54
+ * Added setup checking to Daemon to only run setup when needed.
55
+
56
+ * Moved healthcheck from App to ServerApp and improved the api.
57
+
58
+ * Renamed DeployServerApp to ServerApp.
59
+
60
+ * Renamed App#deploy_path and App#deploys_dir to
61
+ App#root_path and App#deploys_path.
62
+
63
+ * Renamed the 'deploy' command to 'run' to more accurately express it's use.
64
+
65
+ * RsyncRepo#do_checkout fixed to match standard Repo#do_checkout methods.
66
+
67
+ * Sunshine::DATA and Sunshine::PATH are now set when running standalone
68
+ ruby deploy files.
69
+
70
+
71
+ === 0.0.5 / 2010-02-26
72
+
73
+ * Sunshine::App:
74
+
75
+ * Use of DeployServerDispatcher threading
76
+
77
+ * Fixed control script creation to be deploy_server specific
78
+ (takes roles into account)
79
+
80
+ * Added AttiApp class for ATTi app deployment.
81
+
82
+ * Constuctor supports :deploy_name option for nameable deploys.
83
+ Defaults to the timestamp.
84
+
85
+ * Auto-detects if the script's directory is a checked out repo and uses it
86
+ if no repo information was given.
87
+
88
+ * Support for running sass.
89
+
90
+ * Sunshine::DeployServerDispatcher:
91
+
92
+ * Added threading support
93
+
94
+ * Sunshine::Repo:
95
+
96
+ * Added support for detecting a repo type based on a path:
97
+ Repo.detect [path [, console_or_deploy_server]]
98
+ #=> [:git, "git://url/of/git/repo", {:tree => "master", ...}]
99
+
100
+ * Moved info instance methods to the class
101
+
102
+ * Support for git-svn:
103
+ SvnRepo.git_svn? path
104
+
105
+ * Changed the checkout_to method signature
106
+
107
+ * Sunshine::Server:
108
+
109
+ * Added support for ar_sendmail server.
110
+
111
+
112
+ === 0.0.4 / 2010-02-12
113
+
114
+ * Added sudo functionality:
115
+
116
+ * Support for :sudo option on Sunshine::App, Sunshine::Server, and
117
+ Sunshine::DeployServer constructors, and attr_accessor :sudo
118
+
119
+ * Settler Dependency classes support a default sudo value:
120
+ Sunshine::Dependencies::Gem.sudo = true # use sudo
121
+ Sunshine::Dependencies::Gem.sudo = "usr" # use sudo -u usr
122
+ Sunshine::Dependencies::Gem.sudo = false # ensure sudo is off
123
+ Sunshine::Dependencies::Gem.sudo = nil # use :call obj precedence
124
+
125
+ * App supports passing a (yml) file object to the constructor.
126
+ Useful for passing file DATA if desired:
127
+ app = Sunshine::App.new Sunshine::DATA
128
+ app.deploy!{|app| Sunshine::Rainbows.new(app).restart }
129
+ __END__
130
+ #yaml for app goes here...
131
+
132
+ * App class changes:
133
+
134
+ * Changed the format of the App#checkout_path directory
135
+
136
+ * Logrotate setup now has to be called explicitely
137
+
138
+ * Commands functionality expanded:
139
+
140
+ * Support for --sudo and --sudo=user on all Sunshine commands
141
+
142
+ * Added --format option for control commands. Supports txt, yml, json.
143
+
144
+ * Control scripts generated on the remote server now keep deploy-time
145
+ shell_env variables:
146
+
147
+ * Run commands with the --no-env option to run without
148
+ deploy shell_env variables.
149
+
150
+ * Run any script with the app's env variables using:
151
+ /path/to/app/env some_command
152
+ /path/to/app/env EXTRA_VAR=some_value some_command
153
+ Supports all options the env command supports.
154
+
155
+ * Dependency handling now supports apt.
156
+
157
+ * DeployServers now support passing custom flags for ssh and rsync:
158
+ deploy_server = DeployServer.new "svr.com", :rsync_flags => [...]
159
+
160
+ deploy_server.call "some_command",
161
+ :sudo => "user", :flags => '-C'
162
+
163
+ deploy_server.upload "from", "to",
164
+ :sudo => "user", :flags => ['--chmod=ugo=rwX', '-b']
165
+
166
+ deploy_server.download "from", "to",
167
+ :flags => '--ignore-existing'
168
+
169
+ * Repo implementation has significantly changed:
170
+
171
+ * Added support for git repo.
172
+
173
+ * Info about a repo is now retrieved with Repo#get_repo_info:
174
+ repo.get_repo_info deploy_server, checkout_path
175
+
176
+ * Repo constructor supports options hash with :flags option.
177
+
178
+
179
+ === 0.0.3 / 2010-01-29
180
+
181
+ * Many small bugfixes
182
+
183
+ * Tests, tests, and more tests
184
+
185
+ * Changed DeployServer api
186
+
187
+ * DeployServer#run is not longer supported, use DeployServer#call
188
+
189
+ * Constructor supports a spaced delimited list for roles:
190
+ DeployServer.new "myhost.com", :roles => "web db other"
191
+
192
+ * Changed how deploy server yaml is parsed. Should parse to be valid on:
193
+ DeployServer.new *parsed_yaml
194
+ Example Given:
195
+ :deploy_servers :
196
+ - server1.com
197
+ - - server2.com
198
+ - - server3.com
199
+ - :roles : web db other
200
+ :ssh_flags : '-o ControlMaster=auto'
201
+
202
+
203
+ === 0.0.2 / 2010-01-15
204
+
205
+ * Added Control Commands
206
+
207
+ * add, deploy, list, restart, rm, start, stop
208
+
209
+ * Application support
210
+
211
+ * Changed VERSION file to info and its format to yaml
212
+
213
+ * Deployed apps now have a start, stop and restart script
214
+
215
+ * Added Crontab and log rotation support
216
+
217
+ * Functional changes
218
+
219
+ * Ditched net/ssh and net/scp for ssh and rsync through Open4
220
+
221
+ * Fixed and updated dependencies to use Yum
222
+
223
+ * Support for sunshine user configuration in ~/.sunshine
224
+
225
+ * Rake tasks
226
+
227
+ * Support to run the app's rake tasks
228
+
229
+ * Built in default ATTi rake tasks
230
+
231
+
232
+ === 0.0.1 / 2009-11-18
233
+
234
+ * 1 major enhancement
235
+
236
+ * First release!
237
+
data/Manifest.txt ADDED
@@ -0,0 +1,70 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ bin/sunshine
6
+ examples/deploy.rb
7
+ examples/deploy_tasks.rake
8
+ examples/standalone_deploy.rb
9
+ lib/commands/add.rb
10
+ lib/commands/default.rb
11
+ lib/commands/list.rb
12
+ lib/commands/restart.rb
13
+ lib/commands/rm.rb
14
+ lib/commands/run.rb
15
+ lib/commands/start.rb
16
+ lib/commands/stop.rb
17
+ lib/sunshine.rb
18
+ lib/sunshine/app.rb
19
+ lib/sunshine/binder.rb
20
+ lib/sunshine/crontab.rb
21
+ lib/sunshine/daemon.rb
22
+ lib/sunshine/daemons/ar_sendmail.rb
23
+ lib/sunshine/daemons/delayed_job.rb
24
+ lib/sunshine/daemons/nginx.rb
25
+ lib/sunshine/daemons/rainbows.rb
26
+ lib/sunshine/daemons/server.rb
27
+ lib/sunshine/daemons/unicorn.rb
28
+ lib/sunshine/dependencies.rb
29
+ lib/sunshine/dependency_lib.rb
30
+ lib/sunshine/exceptions.rb
31
+ lib/sunshine/healthcheck.rb
32
+ lib/sunshine/output.rb
33
+ lib/sunshine/package_managers/apt.rb
34
+ lib/sunshine/package_managers/dependency.rb
35
+ lib/sunshine/package_managers/gem.rb
36
+ lib/sunshine/package_managers/yum.rb
37
+ lib/sunshine/remote_shell.rb
38
+ lib/sunshine/repo.rb
39
+ lib/sunshine/repos/git_repo.rb
40
+ lib/sunshine/repos/rsync_repo.rb
41
+ lib/sunshine/repos/svn_repo.rb
42
+ lib/sunshine/server_app.rb
43
+ lib/sunshine/shell.rb
44
+ templates/logrotate/logrotate.conf.erb
45
+ templates/nginx/nginx.conf.erb
46
+ templates/nginx/nginx_optimize.conf
47
+ templates/nginx/nginx_proxy.conf
48
+ templates/rainbows/rainbows.conf.erb
49
+ templates/tasks/sunshine.rake
50
+ templates/unicorn/unicorn.conf.erb
51
+ test/fixtures/app_configs/test_app.yml
52
+ test/fixtures/sunshine_test/test_upload
53
+ test/mocks/mock_object.rb
54
+ test/mocks/mock_open4.rb
55
+ test/test_helper.rb
56
+ test/unit/test_app.rb
57
+ test/unit/test_binder.rb
58
+ test/unit/test_crontab.rb
59
+ test/unit/test_git_repo.rb
60
+ test/unit/test_healthcheck.rb
61
+ test/unit/test_nginx.rb
62
+ test/unit/test_rainbows.rb
63
+ test/unit/test_remote_shell.rb
64
+ test/unit/test_repo.rb
65
+ test/unit/test_server.rb
66
+ test/unit/test_server_app.rb
67
+ test/unit/test_shell.rb
68
+ test/unit/test_sunshine.rb
69
+ test/unit/test_svn_repo.rb
70
+ test/unit/test_unicorn.rb
data/README.txt ADDED
@@ -0,0 +1,277 @@
1
+ = Sunshine
2
+
3
+ http://betalabs.yellowpages.com/
4
+
5
+ == Description
6
+
7
+ Sunshine is an object-oriented api for rack application deployment.
8
+
9
+ Sunshine is open and it can do a lot! It's meant to be dug into and understood.
10
+ Knowing how it works will let you do really neat things: classes are
11
+ decoupled as much as possible to allow for optimal flexibility,
12
+ and most can be used independently.
13
+
14
+ This gem was made possible by the sponsoring of AT&T Interactive
15
+ (http://attinteractive.com).
16
+
17
+ == Setup
18
+
19
+ Installing sunshine:
20
+
21
+ gem install sunshine
22
+
23
+ You can either use sunshine by requiring the gem in your script or
24
+ by calling the sunshine command:
25
+
26
+ sunshine run my_deploy.rb -e qa
27
+
28
+
29
+ == Deploy Scripts
30
+
31
+ Writing a Sunshine script is easy:
32
+
33
+ options = {
34
+ :name => 'myapp',
35
+ :repo => {:type => :svn, :url => 'svn://blah...'},
36
+ :root_path => '/usr/local/myapp'
37
+ }
38
+
39
+ options[:remote_shells] = case Sunshine.deploy_env
40
+ when 'qa'
41
+ ['qa1.svr.com', 'qa2.svr.com']
42
+ else
43
+ 'localhost'
44
+ end
45
+
46
+ Sunshine::App.deploy(options) do |app|
47
+
48
+ app_server = Sunshine::Rainbows.new(app)
49
+ app_server.restart
50
+
51
+ Sunshine::Nginx.new(app, :point_to => app_server).restart
52
+
53
+ end
54
+
55
+
56
+ The App::deploy and App::new methods also support passing
57
+ a path to a yaml file:
58
+
59
+ app = Sunshine::App.new("path/to/config.yml")
60
+ app.deploy{|app| Sunshine::Rainbows.new(app).restart }
61
+
62
+
63
+ The yaml file can also be any IO stream whos output will parse to yaml.
64
+ This can be ueful for passing the file's DATA and keep all the deploy
65
+ information in one place:
66
+
67
+ # The following two lines are equivalent:
68
+ app = Sunshine::App.new
69
+ app = Sunshine::App.new Sunshine::DATA
70
+
71
+ app.deploy{|app| Sunshine::Rainbows.new(app).restart }
72
+
73
+ __END__
74
+
75
+ # yaml for app goes here...
76
+
77
+
78
+ Yaml files are read on a deploy-environment basis so its format reflects this:
79
+
80
+ ---
81
+ # Default is always inherited by all environments
82
+ :default :
83
+ :name : app_name
84
+ :repo :
85
+ :type : svn
86
+ :url : svn://subversion/app_name/branches/continuous_integration
87
+
88
+ :root_path : /usr/local/app_name
89
+
90
+ :remote_shells :
91
+ - - localhost
92
+ - :roles : web db app
93
+
94
+ # Setup for qa environment
95
+ :qa :
96
+ :repo :
97
+ :type : svn
98
+ :url : svn://subversion/app_name/tags/release_0001
99
+ :remote_shells :
100
+ - qa1.servers.com
101
+ - qa2.servers.com
102
+
103
+ # Prod inherits top level values from :qa
104
+ :prod :
105
+ :inherits : :qa
106
+ :remote_shells :
107
+ - prod1.servers.com
108
+ - prod2.servers.com
109
+
110
+ In this example, :prod inherits top level values from :qa (only :repo in this
111
+ instance). The :inherits key also supports an array as its value.
112
+
113
+
114
+ == Using rake is great!
115
+
116
+ Although Sunshine comes with it's own bundle of commands, they should be used
117
+ to control deployed apps on remote servers in instances where deploy information
118
+ (e.g. your deploy yaml file) is unavailable. Their purpose is to query a server
119
+ where Sunshine apps have been deployed and have a nominal amount of information
120
+ and control over them. Sunshine control commands are run on a per-server basis.
121
+
122
+ Most of the time though, you'll want to control the deploy on a per-app basis.
123
+ You have the deploy information and you need to do things involving that
124
+ specific deploy. Rake tasks are great for that, and Sunshine comes with a
125
+ template rake file that you can modify to fit your needs.
126
+
127
+ You can copy the template rake file to lib/tasks/ by running:
128
+ sunshine --rakefile lib/tasks/.
129
+
130
+ If you open the file, you'll see a variety of tasks that handle deployment, to
131
+ application start/stop/restart-ing, to health checks. Most likely, the two tasks
132
+ you'll need to update are the :app (for instantiation) and the :deploy tasks.
133
+
134
+ First off, if you're using rails, you'll probably want to update "task :app" to
135
+ "task :app => :environment" in order to get all the rails environment goodness.
136
+ You'll also want to make sure that the @app object gets instantiated with the
137
+ proper hash value or yaml file.
138
+
139
+ Second, you need to update your :deploy task. Add whatever instructions you need
140
+ to the @app.deploy block.
141
+
142
+ And that's it! Try running your Sunshine rake tasks!
143
+
144
+ rake sunshine:app # Instantiate Sunshine
145
+ rake sunshine:db_migrate # Run db:migrate on remote :db servers
146
+ rake sunshine:deploy # Deploy the app
147
+ rake sunshine:health # Get the health state
148
+ rake sunshine:health:disable # Turn off health check
149
+ rake sunshine:health:enable # Turn on health check
150
+ rake sunshine:health:remove # Remove health check
151
+ rake sunshine:info # Get deployed app info
152
+ rake sunshine:restart # Run the remote restart script
153
+ rake sunshine:start # Run the remote start script
154
+ rake sunshine:status # Check if the deployed app is running
155
+ rake sunshine:stop # Run the remote stop script
156
+
157
+
158
+
159
+ == Dependencies
160
+
161
+ Sunshine has simple, basic dependency support, and relies mostly on preexisting
162
+ package manager tools such as apt, yum, or rubygems. Dependencies or packages
163
+ can be defined independently, or as a part of a dependency tree
164
+ (see Sunshine::DependencyLib). Sunshine has its own internal dependency tree
165
+ which can be modified but users can also create their own.
166
+
167
+
168
+ === User Dependencies
169
+
170
+ The most common way of using dependencies is through ServerApp:
171
+
172
+ server_app.apt_install 'postgresql', 'libxslt'
173
+ server_app.gem_install 'json', :version => '>=1.0.0'
174
+
175
+ This should be plenty for most users. You can however create simple standalone
176
+ package definitions:
177
+
178
+ postgresql = Sunshine::Apt.new('postgresql')
179
+ postgresql.install! :call => server_app.shell
180
+
181
+ You can imagine how this would be useful to do server configuration
182
+ with Sunshine:
183
+
184
+ server = RemoteShell.new "user@myserver.com"
185
+ server.connect
186
+
187
+ %w{postgresql libxslt ruby-full rubygems}.each do |dep_name|
188
+ Sunshine::Apt.new(dep_name).install! :call => server
189
+ end
190
+
191
+ Warning: If the :call options isn't specified, the dependency will attempt to
192
+ install on the local system.
193
+
194
+
195
+ === Internal Sunshine Dependencies (advanced)
196
+
197
+ Sunshine's default dependencies are defined in Sunshine.dependencies and can
198
+ be overridden as needed:
199
+
200
+ Sunshine.dependencies.get 'rubygems', :type => Sunshine::Yum
201
+ #=> <Sunshine::Yum ... version='1.3.5' >
202
+ # Not what you want? Replace it:
203
+
204
+ Sunshine.dependencies.yum 'rubygems', :version => '1.3.2'
205
+
206
+ Any dependencies added or modified in Sunshine.dependencies are used as a part
207
+ of the internal Sunshine workings. Also to note: ServerApp#pkg_manager is
208
+ crucial in defining which dependency to use. By default, a server_app's
209
+ package manager will be either Yum or Apt depending on availability. That can
210
+ be overridden with something like:
211
+
212
+ server_app.pkg_manager = Sunshine::Yum
213
+
214
+ An array can also be given and the server_app will attempt to install available
215
+ dependencies according to that type order:
216
+
217
+ server_app.pkg_manager = [Sunshine::Tpkg, Sunshine::Yum]
218
+
219
+ In this instance, if no Tpkg dependency was defined in Sunshine.dependencies,
220
+ the server_app will look for a Yum dependency. If you want to ensure all your
221
+ server_apps use the same dependency definition, you may consider:
222
+
223
+ Sunshine.dependencies.yum 'rubygems', :version => '1.3.2'
224
+ Sunshine.dependencies.apt 'rubygems', :version => '1.3.2'
225
+ # ... and so on
226
+
227
+
228
+ == Deployed Application Control
229
+
230
+ Sunshine has a variety of commands that allow simple control of
231
+ remote or locally deployed applications. These include start, stop, restart
232
+ actions to be taken application-wide, as well as querying for the
233
+ health and state of the app:
234
+
235
+ Examples:
236
+ sunshine run deploy_script.rb
237
+ sunshine restart myapp -r user@server.com,user@host.com
238
+ sunshine list myapp myotherapp --health -r user@server.com
239
+ sunshine list myapp --status
240
+
241
+ The Sunshine commands are as follows:
242
+ add Register an app with sunshine
243
+ list Display deployed apps
244
+ restart Restart a deployed app
245
+ rm Unregister an app with sunshine
246
+ run Run a Sunshine script
247
+ start Start a deployed app
248
+ stop Stop a deployed app
249
+
250
+ For more help on sunshine commands, use 'sunshine COMMAND --help'.
251
+ For more information about control scripts, see the
252
+ Sunshine::App#build_control_scripts method.
253
+
254
+ == LICENSE:
255
+
256
+ (The MIT License)
257
+
258
+ Copyright (c) 2010 FIX
259
+
260
+ Permission is hereby granted, free of charge, to any person obtaining
261
+ a copy of this software and associated documentation files (the
262
+ 'Software'), to deal in the Software without restriction, including
263
+ without limitation the rights to use, copy, modify, merge, publish,
264
+ distribute, sublicense, and/or sell copies of the Software, and to
265
+ permit persons to whom the Software is furnished to do so, subject to
266
+ the following conditions:
267
+
268
+ The above copyright notice and this permission notice shall be
269
+ included in all copies or substantial portions of the Software.
270
+
271
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
272
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
273
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
274
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
275
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
276
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
277
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,46 @@
1
+ # -*- ruby -*-
2
+ require 'rubygems'
3
+ require 'hoe'
4
+ require 'rake'
5
+ require 'rake/testtask'
6
+
7
+ task :manifest do
8
+ manifest_file = "Manifest.txt"
9
+
10
+ gem_files = record_files do |f|
11
+ next if f =~ /^(tmp|pkg|deploy_tests)/
12
+ puts(f)
13
+ true
14
+ end
15
+
16
+ gem_files.push(manifest_file)
17
+ gem_files = gem_files.uniq.sort.join("\n")
18
+
19
+ File.open(manifest_file, "w+") do |file|
20
+ file.write gem_files
21
+ end
22
+ end
23
+
24
+ def record_files(path="*", file_arr=[], &block)
25
+ Dir[path].each do |child_path|
26
+ if File.file?(child_path)
27
+ next if block_given? && !yield(child_path)
28
+ file_arr << child_path
29
+ end
30
+ record_files(child_path+"/*", file_arr, &block) if
31
+ File.directory?(child_path)
32
+ end
33
+ return file_arr
34
+ end
35
+
36
+ Hoe.plugin :isolate
37
+
38
+ Hoe.spec 'sunshine' do |p|
39
+ developer('Jeremie Castagna', 'jcastagna@attinteractive.com')
40
+ self.extra_deps << ['open4', '>= 1.0.1']
41
+ self.extra_deps << ['rainbow', '>= 1.0.4']
42
+ self.extra_deps << ['highline', '>= 1.5.1']
43
+ end
44
+
45
+ # vim: syntax=Ruby
46
+
data/bin/sunshine ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby -w
2
+
3
+ require 'sunshine'
4
+
5
+ Sunshine.run
@@ -0,0 +1,61 @@
1
+ Sunshine::App.deploy do |app|
2
+
3
+ app.shell_env "NLS_LANG" => "American_America.UTF8",
4
+ "TNS_ADMIN" => "#{app.current_path}/config",
5
+ "ORACLE_HOME" => "/usr/lib/oracle/11.2/client64",
6
+ "LD_LIBRARY_PATH" => "/usr/lib/oracle/11.2/client64/lib"
7
+
8
+ app.gem_install 'isolate', :version => '1.3.0'
9
+
10
+ app.install_deps 'libxml2-devel', 'libxslt-devel', 'libaio', 'sqlite-devel',
11
+ 'sqlite', 'ruby-devel', 'activerecord-oracle_enhanced-adapter'
12
+
13
+
14
+ app.run_bundler
15
+
16
+
17
+ app.with_filter :role => :db do
18
+
19
+ app.rake 'config/database.yml'
20
+ app.rake 'db:migrate'
21
+ end
22
+
23
+
24
+ app.with_filter :role => :cdn do
25
+
26
+ sass_yml_file = "#{app.checkout_path}/config/asset_packages.yml"
27
+ sass_yml = app.server_apps.first.shell.call "cat #{sass_yml_file}"
28
+ sass_files = YAML.load(sass_yml)['stylesheets']
29
+
30
+ app.sass sass_files
31
+ app.rake 'asset:packager:build_all'
32
+ end
33
+
34
+
35
+ delayed_job = Sunshine::DelayedJob.new app
36
+ delayed_job.restart
37
+
38
+ mail = Sunshine::ARSendmail.new app
39
+ mail.restart
40
+
41
+ unicorn = Sunshine::Unicorn.new app, :port => 10001, :processes => 8
42
+ unicorn.restart
43
+
44
+ nginx = Sunshine::Nginx.new app, :point_to => unicorn, :port => 10000
45
+ nginx.restart
46
+ end
47
+
48
+
49
+ __END__
50
+
51
+ :default:
52
+ :repo:
53
+ :type: git
54
+ :url: git://my_git_server.com/app_name.git
55
+ :flags: "--depth 5"
56
+
57
+ :root_path: ~my_user/app_name
58
+
59
+ :remote_shells:
60
+ - myserver1.com
61
+ - myserver2.com