Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

Commit

Permalink
Merge pull request #527 from gamechanger/js-bundle-services
Browse files Browse the repository at this point in the history
Js bundle services
  • Loading branch information
jsingle committed Aug 19, 2015
2 parents 956627d + b3c9959 commit 5b93722
Show file tree
Hide file tree
Showing 17 changed files with 165 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* The `restart` command no longer takes a `--no-sync` flag, due to the move to NFS.
* **New**
* Dusty now attempts to fix a known problem with boot2docker networking, resulting in up to a 10x improvement in network performance. See [this boot2docker issue](https://github.com/boot2docker/boot2docker/issues/1022) for more information.
* Bundles can now specify services, just as they specify apps.
* **Misc**
* `test.once` commands that fail now cause the entire test run to fail immediately.
* When running all test suites, a tabular summary of test results is now printed at the end of the run
Expand Down
15 changes: 15 additions & 0 deletions docs/specs/bundle-specs.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,18 @@ apps:
The list of apps to be run by `dusty up` if this bundle is activated.
These apps are used as entrypoints into the dependency graph defined by
your app and service specs.

Each bundle must specify at least one app (in `apps`) or service (in `services`).

## services

```
services:
- postgres
```

A list of services which will be run by `dusty up` if this bundle is activated.
Services specified here will be launched in addition to services
that specified apps depend on.

Each bundle must specify at least one app (in `apps`) or service (in `services`).
6 changes: 5 additions & 1 deletion dusty/compiler/spec_assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,16 @@ def _get_referenced_libs(specs):

def _get_referenced_services(specs):
"""
Returns all services that are referenced in specs.apps.depends.services
Returns all services that are referenced in specs.apps.depends.services,
or in specs.bundles.services
"""
active_services = set()
for app_spec in specs['apps'].values():
for service in app_spec['depends']['services']:
active_services.add(service)
for bundle_spec in specs['bundles'].values():
for service in bundle_spec['services']:
active_services.add(service)
return active_services

def _filter_active(spec_type, specs):
Expand Down
11 changes: 9 additions & 2 deletions dusty/schemas/bundle_schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
from schemer import Schema, Array

def app_or_service_required_validator():
def validator(document):
if 'apps' not in document and 'services' not in document:
return 'Bundles must specify `apps` or `services`'
return validator

bundle_schema = Schema({
'description': {'type': basestring, 'default': ''},
'apps': {'type': Array(basestring), 'required': True}
})
'apps': {'type': Array(basestring), 'default': list},
'services': {'type': Array(basestring), 'default': list},
}, validates=[app_or_service_required_validator()])
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repo: github.com/gamechanger/simpleapp
image: docker.gamechanger.io/simpleapp
mount: /simpleapp
commands:
always:
- run-script.sh
compose:
environment:
gcenv: local
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
bundles:
simple:
apps:
- simpleapp
services:
- bundle-specified-service
apps:
simpleapp:
image: docker.gamechanger.io/simpleapp
commands:
always:
- run-script.sh
once: []
compose:
environment:
gcenv: local
volumes: []
depends:
apps: []
libs: []
services: []
libs: {}
services:
bundle-specified-service:
image: someimage
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apps:
- simpleapp
services:
- bundle-specified-service
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
simpleapp:
image: docker.gamechanger.io/simpleapp
command: run-script.sh
environment:
gcenv: local
bundle-specified-service:
image: someimage
21 changes: 21 additions & 0 deletions tests/unit/compiler/test_configs/bundle_with_service/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
worker_processes 1;

error_log /var/log/dusty/nginx/error.log;

pid /var/log/dusty/nginx/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

access_log /var/log/dusty/nginx/access.log;

sendfile on;

keepalive_timeout 65;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
image: someimage
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repo: github.com/gamechanger/simpleapp
image: docker.gamechanger.io/simpleapp
mount: /simpleapp
commands:
always:
- run-script.sh
compose:
environment:
gcenv: local
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
bundles:
simple:
apps:
- simpleapp
serviceonly:
services:
- bundle-specified-service
apps:
simpleapp:
image: docker.gamechanger.io/simpleapp
commands:
always:
- run-script.sh
once: []
compose:
environment:
gcenv: local
volumes: []
depends:
apps: []
libs: []
services: []
libs: {}
services:
bundle-specified-service:
image: someimage
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
services:
- bundle-specified-service
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
apps:
- simpleapp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
simpleapp:
image: docker.gamechanger.io/simpleapp
command: run-script.sh
environment:
gcenv: local
bundle-specified-service:
image: someimage
21 changes: 21 additions & 0 deletions tests/unit/compiler/test_configs/bundle_without_app/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
worker_processes 1;

error_log /var/log/dusty/nginx/error.log;

pid /var/log/dusty/nginx/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

access_log /var/log/dusty/nginx/access.log;

sendfile on;

keepalive_timeout 65;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
image: someimage

0 comments on commit 5b93722

Please sign in to comment.