{"_id":"54b35fe473abe90b00106f78","project":"54b2c91287873d1f00dbebdb","__v":4,"user":"54a3af95ad78941600ca2e2a","version":{"_id":"54b2c93f336cfb0b00608c28","forked_from":"54b2c91287873d1f00dbebde","project":"54b2c91287873d1f00dbebdb","__v":4,"createdAt":"2015-01-11T19:04:31.031Z","releaseDate":"2015-01-11T19:04:31.031Z","categories":["54b2c93f336cfb0b00608c29","54b2cb87db3c741400eac8c2","54b35d86aad2810b009507d7","54b35d91aad2810b009507d8"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"0.4.0","version":"0.4.0"},"category":{"_id":"54b35d91aad2810b009507d8","pages":["54b35fe473abe90b00106f78","54b361b1d8ea260b00e4e5eb"],"version":"54b2c93f336cfb0b00608c28","__v":2,"project":"54b2c91287873d1f00dbebdb","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-01-12T05:37:21.902Z","from_sync":false,"order":1,"slug":"running-services","title":"Running Services"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-01-12T05:47:16.599Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"Bosco knows about all of your repositories, so it isn't a big stretch to also have Bosco provide some helpful tools for starting, stopping, watching and restarting your services.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Node Services\"\n}\n[/block]\nIf your project is a node project, Bosco will look for a 'start' script within the package.json, and start the project via [PM2](https://github.com/Unitech/pm2).\n\nAn extract from one of our service package.json files can be seen below:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n  \\\"name\\\": \\\"service-resource-api\\\",\\n  \\\"version\\\": \\\"0.0.1\\\",\\n  \\\"description\\\": \\\"Resource API\\\",\\n  \\\"main\\\": \\\"service.js\\\",\\n  \\\"scripts\\\": {\\n    \\\"start\\\": \\\"node cluster\\\",\\n    \\\"test\\\": \\\"make acceptance-test\\\",\\n    \\\"lint\\\": \\\"make lint\\\"\\n  }\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nTo start this project:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"bosco run -r resource-api\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Docker\"\n}\n[/block]\nAt TES we use Docker to manage all of the infrastructure elements that development teams may depend on, as well as the packaging and deployment of services in the live environments. \n\nTo make use of Docker images during development, we have Bosco do the stopping / starting of them for you.  For this to work, you need to create a bosco-service.json file within the service repository that is the infrastructure - for example, the file below is for our mongodb Docker image:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n\\t\\\"tags\\\": [\\\"upload\\\", \\\"search\\\"],\\n\\t\\\"service\\\": {\\n\\t\\t\\\"type\\\":\\\"docker\\\",\\n\\t\\t\\\"name\\\":\\\"infra-mongodb\\\",\\n\\t\\t\\\"registry\\\":\\\"docker-registry.tescloud.com\\\",\\n\\t\\t\\\"username\\\": \\\"tescloud\\\",\\n\\t\\t\\\"version\\\": \\\"latest\\\",\\n    \\\"alwaysPull\\\": true,\\n    \\\"checkTimeout\\\": 30000,\\n    \\\"docker\\\":{\\n      \\\"HostConfig\\\": {\\n        \\\"PortBindings\\\": {\\n          \\\"27017/tcp\\\": [{\\n            \\\"HostIp\\\": \\\"0.0.0.0\\\",\\n            \\\"HostPort\\\": \\\"27017\\\"\\n          }],\\n          \\\"28017/tcp\\\":  [{\\n            \\\"HostIp\\\": \\\"0.0.0.0\\\",\\n            \\\"HostPort\\\": \\\"28017\\\"\\n          }]\\n        }\\n      }\\n    }\\n\\t}\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nBosco will simply use this configuration to pull the Docker image from the registry and run it locally.\n\nTo start this project:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"bosco run -r mongodb\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\nNote that Bosco does not package up and run the project from its source, so any changes made in the project are not reflected immediately.  At the moment our build server creates the docker images when it is pushed and publishes to the registry, which means if you are working on infrastructure images at the moment the end to end flow is relatively cumbersome.\n\nWe have so far not found this to be an issue as in most instances infra-* projects tend to be very slow moving and change relatively infrequently.","excerpt":"Have bosco run your stuff","slug":"introduction","type":"basic","title":"Basics"}

Basics

Have bosco run your stuff

Bosco knows about all of your repositories, so it isn't a big stretch to also have Bosco provide some helpful tools for starting, stopping, watching and restarting your services. [block:api-header] { "type": "basic", "title": "Node Services" } [/block] If your project is a node project, Bosco will look for a 'start' script within the package.json, and start the project via [PM2](https://github.com/Unitech/pm2). An extract from one of our service package.json files can be seen below: [block:code] { "codes": [ { "code": "{\n \"name\": \"service-resource-api\",\n \"version\": \"0.0.1\",\n \"description\": \"Resource API\",\n \"main\": \"service.js\",\n \"scripts\": {\n \"start\": \"node cluster\",\n \"test\": \"make acceptance-test\",\n \"lint\": \"make lint\"\n }\n}", "language": "json" } ] } [/block] To start this project: [block:code] { "codes": [ { "code": "bosco run -r resource-api", "language": "text" } ] } [/block] [block:api-header] { "type": "basic", "title": "Docker" } [/block] At TES we use Docker to manage all of the infrastructure elements that development teams may depend on, as well as the packaging and deployment of services in the live environments. To make use of Docker images during development, we have Bosco do the stopping / starting of them for you. For this to work, you need to create a bosco-service.json file within the service repository that is the infrastructure - for example, the file below is for our mongodb Docker image: [block:code] { "codes": [ { "code": "{\n\t\"tags\": [\"upload\", \"search\"],\n\t\"service\": {\n\t\t\"type\":\"docker\",\n\t\t\"name\":\"infra-mongodb\",\n\t\t\"registry\":\"docker-registry.tescloud.com\",\n\t\t\"username\": \"tescloud\",\n\t\t\"version\": \"latest\",\n \"alwaysPull\": true,\n \"checkTimeout\": 30000,\n \"docker\":{\n \"HostConfig\": {\n \"PortBindings\": {\n \"27017/tcp\": [{\n \"HostIp\": \"0.0.0.0\",\n \"HostPort\": \"27017\"\n }],\n \"28017/tcp\": [{\n \"HostIp\": \"0.0.0.0\",\n \"HostPort\": \"28017\"\n }]\n }\n }\n }\n\t}\n}", "language": "json" } ] } [/block] Bosco will simply use this configuration to pull the Docker image from the registry and run it locally. To start this project: [block:code] { "codes": [ { "code": "bosco run -r mongodb", "language": "text" } ] } [/block] Note that Bosco does not package up and run the project from its source, so any changes made in the project are not reflected immediately. At the moment our build server creates the docker images when it is pushed and publishes to the registry, which means if you are working on infrastructure images at the moment the end to end flow is relatively cumbersome. We have so far not found this to be an issue as in most instances infra-* projects tend to be very slow moving and change relatively infrequently.