├── .gitignore ├── LICENSE.txt ├── README.md ├── docker └── level │ ├── Dockerfile │ └── package.json ├── fuge ├── all-dev.yml ├── compose-dev.yml ├── fuge-config.js ├── infrastructure.yml └── package.json ├── iteration.sh └── system ├── base-node.js ├── msgstats.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | lib-cov 2 | *.seed 3 | *.log 4 | *.csv 5 | *.dat 6 | *.out 7 | *.pid 8 | *.gz 9 | 10 | pids 11 | logs 12 | results 13 | 14 | npm-debug.log 15 | 16 | config.mine.js 17 | 18 | node_modules 19 | 20 | test/load/*.data 21 | test/elasticsearch-* 22 | 23 | *~ 24 | .DS_Store 25 | tmp 26 | 27 | workspace 28 | 29 | builds 30 | build 31 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2012-2014 Richard Rodger 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Nodezoo][Banner] 2 | 3 | # nodezoo-workshop 4 | 5 | - __Lead:__ [Richard Rodger][Lead] 6 | - __Sponsor:__ [nearForm][Sponsor] 7 | 8 | A workshop for the [nodezoo](http://nodezoo.com) project. Nodezoo is a search engine for 9 | [Node.js](http://nodejs.org) modules. The nodezoo search engine is an example of a real-world 10 | service built using Node.js microservices. Each microservice is published in its own github 11 | repository along with all of the necessary config to run the system locally or live . The codebase 12 | is intended to be used as an example, and as a starting point for your own projects. 13 | 14 | Below we provide a complete workshop to work through. Our current live system has it's roots in 15 | this workshop. By working through the iterations below you can get a feel for how a microservice 16 | system is bootstrapped together and how the system evolves as needs change. 17 | 18 | __Note:__ This repo contains the nodezoo workshop, to explore and run the live version of nodezoo, 19 | please see [nodezoo-system][] project. 20 | 21 | 22 | 23 | ## Microservices 24 | 25 | The micro-services that make up the system are: 26 | 27 | * [nodezoo-web](http://github.com/nodezoo/nodezoo-web): the web server 28 | * [nodezoo-info](http://github.com/nodezoo/nodezoo-info): collect data on modules from multiple sources 29 | * [nodezoo-search](http://github.com/nodezoo/nodezoo-search): interface with an elasticsearch server 30 | * [nodezoo-npm](http://github.com/nodezoo/nodezoo-npm): interface with the NPM registry 31 | * [nodezoo-github](http://github.com/nodezoo/nodezoo-github): interface with github.com 32 | * [nodezoo-npm-update](http://github.com/nodezoo/nodezoo-npm-update): get live module updates 33 | 34 | Each service should be downloaded and placed in the same folder including this repository. 35 | 36 | ## Iterations 37 | 38 | The system is built in a set of iterations so that you can follow its 39 | development. This mirrors the way that real microservice projects are 40 | developed. Each iteration, more services are introduced. 41 | 42 | When working with the individual microservices, it is easier to open a 43 | separate terminal for each one. 44 | 45 | Not all microservices are available in all iterations, as some are 46 | only introduced later. 47 | 48 | Each iterations contains a set of tasks to execute. You should try to 49 | get them all up and running to verify to yourself that you understand 50 | the mechanics of the system. 51 | 52 | Each iteration also includes a set of experiments that you can 53 | attempt. Use these to develop your understanding of the system - there 54 | are no right answers! 55 | 56 | 57 | ## Requirements 58 | 59 | The basic tools are: 60 | 61 | * [Node.js 4](http://nodejs.org) 62 | * [Docker 1.8](http://docker.com) 63 | 64 | Install these before getting started. Later iterations introduce additional tools, and these will be indicated. 65 | 66 | ### A Note on Docker 67 | 68 | This example only places microservices into containers. All other 69 | services (e.g. redis) are run as normal from the host machine. This does not 70 | prevent you from containerising them of course! 71 | 72 | To use the _docker_ command in a terminal, you need to set up the docker environment variables. 73 | From the initial docker terminal (as provided by the docker installation), you can run 74 | 75 | ```sh 76 | $ docker-machine env default 77 | ``` 78 | 79 | to obtain these environment settings. Copy and paste them into new terminals as needed. 80 | 81 | Docker runs containers in a host machine. You use the IP address of this host to access containers. 82 | The easiest way to get this IP address is to run the command: 83 | 84 | ```sh 85 | $ docker-machine ip default 86 | ``` 87 | 88 | Finally, from inside docker containers, your microservices will need to talk to the outside world. 89 | To do this, they use a special IP address representing your host machine (Host IP). You can obtain this address in multiple ways: 90 | 91 | * run `ifcongig -a` and look for the docker or virtualbox entries. 92 | * run `docker-machine inspect default | grep HostOnly` 93 | 94 | Docker networking can be tricky, and is fragile with respect to network changes, with DNS, for example, failing. 95 | When wierdness happens, your best bet is to restart: 96 | 97 | ```sh 98 | $ docker-machine restart default 99 | ``` 100 | 101 | This will invalidate your environment, so you will need to launch a new docker terminal. 102 | 103 | 104 | ## How to use this code 105 | 106 | Each microservice repository has a branch for each iteration: i00, i01, etc. 107 | You can clone these branches directly - for example: 108 | 109 | ```sh 110 | $ git clone -b i00 https://github.com/nodezoo/nodezoo-web.git nodezoo-web-i00 111 | ``` 112 | 113 | However you will not be able to save your changes to your own repositories. 114 | 115 | To save your own work, it is better to first fork the repository on github.com, and then 116 | 117 | ```sh 118 | $ git clone https://github.com/[YOUR_USER]/nodezoo-web.git 119 | $ cd nodezoo-web 120 | $ git remote add upstream https://github.com/nodezoo/nodezoo-web.git 121 | $ git fetch upstream 122 | $ git checkout upstream/i00 123 | $ git checkout -b i00 124 | ``` 125 | 126 | This sequence of commands downloads the branch into your local clone of your fork. 127 | You can then push your changes back to your own fork. 128 | 129 | 130 | One you have downloaded all the branches, you can switch between them, 131 | across all microservice repositories using the `iteration.sh` script: 132 | 133 | 134 | ``` 135 | $ ./iteration.sh i00 # moves all to iteration 00 136 | $ ./iteration.sh i01 # moves all to iteration 01 137 | ... etc. 138 | ``` 139 | 140 | These commands must be used before using the above script, for each branch for the first time : 141 | ``` 142 | $ git checkout upstream/[BRANCH NAME] 143 | $ git checkout -b [BRANCH NAME] 144 | ``` 145 | 146 | ## Install your dependencies 147 | This script only works once the branch has been fully set-up for a first time. 148 | 149 | In each branch, you always need to run the following command: 150 | ``` 151 | npm install 152 | ``` 153 | Then go into the folder nodezoo-workshop/system and run: 154 | ``` 155 | npm install 156 | ``` 157 | to get the dependent Node.js modules. 158 | This must be done each time a branch is changed for each micro-service. 159 | ## Run build 160 | 161 | In the folder nodezoo-web use the following command : 162 | ``` 163 | npm run build 164 | ``` 165 | IMPORTANT NOTE: the build command is not required on branch i00 - i05 166 | 167 | 168 | ## Iteration 00: Getting Started 169 | ### Branch name: `i00` 170 | 171 | This branch starts with a simple web server. Use this branch to validate your configuration. 172 | 173 | ### microservices 174 | * _web_ (stub) 175 | 176 | ### tasks 177 | * Clone the microservice. 178 | * Review code. 179 | * Run in terminal with 180 | * `node srv/app-dev.js --seneca.options.tag=web --seneca.log.all` 181 | * Verify functionality: 182 | * Observe the seneca logs to follow the execution of action patterns 183 | * Open http://localhost:8000 - all searches return "foo" 184 | * Open http://localhost:8000/info/express - all info is for "foo" 185 | * Use the HTTP API: 186 | * `$ curl "http://localhost:44000/act?role=search&cmd=search&query=express"` 187 | * Use the repl: 188 | * `$ telnet localhost 43000` 189 | * `> seneca.list('role:search')` 190 | * `> role:search,cmd:search,query:express` 191 | * Docker image and container: build and run 192 | * Open the Dockerfile in a text editor and the commands to use that Dockerfile are in its comments 193 | * The command `$ docker build -t TAG-NAME .` tells docker to build with the tag TAG-NAME using the Dockerfile in the current directory 194 | * Verify functionality as above, against docker host IP 195 | * If Docker cannot connect to the Docker daemon during building use the following command before building: 196 | `$ eval "$(docker-machine env default)"` 197 | 198 | ### experiments 199 | 200 | * Learn some [hapi](http://hapijs.com): add some more API end points 201 | * how about /api/ping, and respond with the time? 202 | * Learn some [seneca](http://senecajs.org): add some more actions, and expose them as API end points 203 | * how about /api/ping triggers role:web,cmd:ping, and that responds with the time 204 | * The front end is old-school jQuery - how about some [react](http://reactjs.com)? 205 | * Setup nginx as a load-balancer with multiple instances of _web_ running 206 | * update the configuration to handle port conflicts 207 | 208 | 209 | ## Iteration 01: 3 Microservices 210 | ### Branch name: `i01` 211 | 212 | This branch introduces two microservices that support the web 213 | service. Both are stubs that perform no actual work, instead returning 214 | hard-coded responses. The focus here is on understanding how simple 215 | microservice communication is configured using static addressing with 216 | fixed IP addresses and ports. 217 | 218 | ### microservices 219 | * _web_ 220 | * _info_ (stub) 221 | * _search_ (stub) 222 | 223 | ### tasks 224 | * Clone the microservices. 225 | * Review code for each one - in particular the message transport configuration. 226 | * Run in separate terminals with 227 | * `node srv/app-dev.js --seneca.options.tag=web --seneca.log.all` 228 | * `node srv/info-dev.js --seneca.options.tag=info --seneca.log.all` 229 | * `node srv/search-dev.js --seneca.options.tag=search --seneca.log.all` 230 | * Verify functionality: 231 | * Observe the seneca logs to follow the execution of action patterns 232 | * Open http://localhost:8000 - all searches return "bar" 233 | * Open http://localhost:8000/info/express - all info is for "bar" 234 | * Use the HTTP API: 235 | * `$ curl "http://localhost:44000/act?role=search&cmd=search&query=express"` 236 | * Use the repl of each microservice, and test its action patterns 237 | * Build and run the Docker containers, and verify the same functionality 238 | 239 | ### experiments 240 | * Add another microservice 241 | * ... perhaps ping can live in its own service? 242 | * How would you unit test this code? 243 | * testing the inbound and outbound messsages for each action is a good place to start 244 | * What happens when microservices are down? 245 | * Perhaps an auto-restarter like [forever](https://github.com/foreverjs/forever) might help 246 | * Place the _info_ and/or _search_ microservices behind nginx 247 | * and run multiple instances of them - scaling! 248 | * and run multiple versions - fine-grained deployment! 249 | * a simple change is to return 'zed' instead of 'bar' 250 | * Seneca lets you merge microservices into one process 251 | * just seneca.use each microservice inside _web_ 252 | 253 | ## Iteration 02: Real Functionality 254 | ### Branch name: `i02` 255 | 256 | This branch introduces infrastructure services that are used by the 257 | microservices to perform work. Elasticsearch is used as a search 258 | engine, and Redis is used for publish/subscribe messaging. The search 259 | can now index and search for Node.js modules, with some manual help. 260 | 261 | ### Prerequisites 262 | 263 | * Install [redis](http://redis.io/) and run in default configuration 264 | * Install [elasticsearch](https://www.elastic.co/) and run in default configuration 265 | * Clone the [nodezoo](https://github.com/nodezoo/nodezoo-workshop) repository, and build the _nodezoo-level_ container 266 | * See folder `docker/level`; run `npm install first` 267 | * This is necessary, as the _seneca-level-store_ module must compile binaries 268 | 269 | ### microservices 270 | 271 | * _web_ 272 | * _info_ 273 | * _search_ 274 | * _npm_ 275 | 276 | ### supporting services 277 | 278 | * _redis_ 279 | * _elasticsearch_ 280 | 281 | ### tasks 282 | * Clone the microservices. 283 | * Review code for each one - in particular the external intergrations. 284 | * Run in separate terminals with 285 | * `node srv/app-dev.js --seneca.options.tag=web --seneca.log.all` 286 | * `node srv/info-dev.js --seneca.options.tag=info --seneca.log.all` 287 | * `node srv/search-dev.js --seneca.options.tag=search --seneca.log.all` 288 | * `node srv/npm-dev.js --seneca.options.tag=npm --seneca.log.all` 289 | * Verify functionality: 290 | * Observe the seneca logs to follow the execution of action patterns 291 | * Open http://localhost:8000/info/request - adds _request_ to the search engine 292 | * Manually change the module name in the URL to index other modules. 293 | * Open http://localhost:8000 - searches now work! Try "request". 294 | * Use the HTTP API: 295 | * `$ curl "http://localhost:44000/act?role=search&cmd=search&query=express"` 296 | * Use the repl of each microservice, and test its action patterns 297 | * Build and run the Docker containers, and verify the same functionality 298 | 299 | ### experiments 300 | 301 | * Add another info microservice 302 | * copy npm, and then modify 303 | * perhaps it would be useful to know something about the author(s) of the module? 304 | * What happens when microservices are down? and what about redis and elasticsearch? 305 | * Can you run multiple copies of _npm_ 306 | * what happens? 307 | * If you used nginx for scaling, does it still work? 308 | * Elasticsearch might run slow - is there a way to deal with this? 309 | * what about a separate caching microservice that sits in front of _search_? 310 | 311 | 312 | ## Iteration 03: Measurement 313 | 314 | ### Branch name: `i03` 315 | 316 | This branch uses influxdb and grafana to chart message flow rates 317 | through the system. Influxdb is used due to it's ease of installation and because it is based on plotting time-series data. Grafana is used because it officially supports influx, and is relatively easy to use. 318 | 319 | ### Prerequisites 320 | 321 | * Install [influxdb](https://influxdb.com/) and run in default configuration 322 | * Start influxdb with `$ influxd run` 323 | * Set up your database by running the console `$ influx` 324 | 325 | ```sql 326 | > CREATE DATABASE seneca_msgstats; 327 | > CREATE USER msgstats WITH PASSWORD 'msgstats'; 328 | > GRANT ALL ON seneca_msgstats TO msgstats; 329 | ``` 330 | 331 | * Install [grafana](http://grafana.org/) and run in default configuration 332 | * You'll need to add your [influxdb](http://docs.grafana.org/datasources/influxdb/) as data source and setup a [dashboard](http://docs.grafana.org/guides/gettingstarted/). 333 | * Action flow rates can be obtained using queries of the form: 334 | * `SELECT SUM(c) FROM "cmd:search,role:search" WHERE time > now() - 100s GROUP BY time(1s)` 335 | * In your clone of the main _nodezoo_ repository, run the msgstats service: 336 | * located in the `system` folder 337 | * `npm install` first as usual 338 | * run with `HOST=localhost|host-ip node msgstats.js` 339 | * use host-ip for docker scenario 340 | * You'll need a personal access token for the github.com API 341 | * See the menu item under account settings on github.com 342 | 343 | ### microservices 344 | 345 | * _web_ (stats) 346 | * _info_ (stats) 347 | * _search_ 348 | * _npm_ 349 | * _github_ 350 | 351 | ### supporting services 352 | 353 | * _redis_ 354 | * _elasticsearch_ 355 | * _influxdb_ 356 | * _grafana_ 357 | * _msgstats_ 358 | 359 | ### tasks 360 | * Clone the microservices. 361 | * Review code for each one - in particular the message statistics collection. 362 | * Run in separate terminals with 363 | * `node srv/app-dev.js --seneca.options.tag=web --seneca.log.all` 364 | * `node srv/info-dev.js --seneca.options.tag=info --seneca.log.all` 365 | * `node srv/search-dev.js --seneca.options.tag=search --seneca.log.all` 366 | * `node srv/npm-dev.js --seneca.options.tag=npm --seneca.log.all` 367 | * `node srv/github-dev.js --seneca.options.tag=npm --seneca.log.all --seneca.options.plugin.github.token=YOUR_GITHUB_TOKEN` 368 | * Verify functionality: 369 | * Observe the seneca logs to follow the execution of action patterns 370 | * Use the website, API and repl as before 371 | * Verify that message flow rate charts are generated in grafana 372 | * Build and run the Docker containers, and verify the same functionality 373 | 374 | ### experiments 375 | 376 | * Write a test script to generate queries via HTTP and then observe the charts 377 | * the message flow rates should remain relatively proportional to each other 378 | * Write a seneca plugin that induces a failure rate on a given set of messages 379 | * read the article on [priors](http://senecajs.org/tutorials/understanding-prior-actions.html) 380 | * run this on _npm_ and _github_ - does running more instances of these services help? 381 | * Can you implement a rate limiter? 382 | * Use your test script to overload the system 383 | * Use a plugin to implement the rate limiting 384 | * It's ok to drop excess load on the floor (aka "load-shedding") 385 | 386 | 387 | ## Iteration 04: Enhancement 388 | ### Branch name: `i04` 389 | 390 | This branch shows the use of a message bus to avoid the high coupling and configuration costs of 391 | direct service-to-service communication. This is one way to avoid the need for service discovery 392 | solutions. 393 | 394 | ### Prerequisites 395 | 396 | * Install [beanstalkd](http://kr.github.io/beanstalkd/) and run in default configuration 397 | 398 | ### microservices 399 | 400 | * _web_ (stats) 401 | * _info_ (stats) 402 | * _search_ 403 | * _npm_ (stats) 404 | * _github_ 405 | * _update_ (stats) 406 | 407 | ### supporting services 408 | 409 | * _redis_ 410 | * _elasticsearch_ 411 | * _influxdb_ 412 | * _grafana_ 413 | * _msgstats_ 414 | 415 | ### tasks 416 | * Clone the microservices. 417 | * Review code for each one - in particular the npm update event emitter. 418 | * Run in separate terminals with 419 | * `node srv/app-dev.js --seneca.options.tag=web --seneca.log.all` 420 | * `node srv/info-dev.js --seneca.options.tag=info --seneca.log.all` 421 | * `node srv/search-dev.js --seneca.options.tag=search --seneca.log.all` 422 | * `node srv/npm-dev.js --seneca.options.tag=npm --seneca.log.all` 423 | * `node srv/github-dev.js --seneca.options.tag=npm --seneca.log.all --seneca.options.plugin.github.token=YOUR_GITHUB_TOKEN` 424 | * `node srv/update-dev.js --seneca.options.tag=update --seneca.log.all --seneca.options.plugin.npm_update.task=registry_subscribe` 425 | * Verify functionality: 426 | * Observe the seneca logs to follow the execution of action patterns 427 | * Use the website, API and repl as before 428 | * Verify that live npm publishes are registered 429 | * Verify that message flow rate charts are generated in grafana 430 | * Build and run the Docker containers, and verify the same functionality 431 | 432 | ### experiments 433 | 434 | * The npm-update microservice also provides download and batch functionality 435 | * experiment with these (look at the source to see the action patterns) 436 | * use the repl to control and observe 437 | * In production, how can you ensure that you have all the npm registry data? 438 | * which configuration of npm-update instances do you run? 439 | * A long time ago, in a galaxy far away, the original nodezoo could calculate "node rank", which is just like "page rank" only for node modules. 440 | * https://github.com/nodezoo/nodezoo-workshop/tree/bdd18c030ef32f19e0b28e1f7ed30f80a9854b59/bin 441 | * Perhaps this can be turned into a batch processing microservice? 442 | 443 | 444 | ### Iteration 05: Mesh Networking 445 | ### Branch name: `i05` 446 | 447 | This branch shows the use of mesh networking to completely remove the need for service discovery. 448 | The [seneca-mesh](https://github.com/rjrodger/seneca-mesh) plugin uses the [SWIM gossip algorithm](http://www.cs.cornell.edu/~asdas/research/dsn02-SWIM.pdf) 449 | to enable microservices to automatically discover the appropriate destinations for messages dynamically. 450 | 451 | ### Prerequisites 452 | 453 | * In your clone of the main _nodezoo_ repository, run the base-node service: 454 | * located in the `system` folder 455 | * `npm install` first as usual 456 | * run with `node base-node.js` 457 | 458 | ### microservices 459 | 460 | * _web_ 461 | * _info_ 462 | * _search_ 463 | * _npm_ 464 | * _github_ 465 | * _update_ 466 | 467 | ### supporting services 468 | 469 | * _influxdb_ 470 | * _grafana_ 471 | * _msgstats_ 472 | * _base-node_ 473 | 474 | ### tasks 475 | * Clone the microservices. 476 | * Review code for each one - in particular the updated service scripts in the `srv` folders. 477 | * Make sure to run the _base-node_ service *before* starting the microservices. 478 | * Run in separate terminals with 479 | * `node srv/app-dev.js --seneca.options.tag=web --seneca.log=type:act --seneca.options.debug.short_logs=true` 480 | * `node srv/info-dev.js --seneca.options.tag=info --seneca.log=type:act --seneca.options.debug.short_logs=true` 481 | * `node srv/search-dev.js --seneca.options.tag=search --seneca.log=type:act --seneca.options.debug.short_logs=true` 482 | * `node srv/npm-dev.js --seneca.options.tag=npm --seneca.log=type:act --seneca.options.debug.short_logs=true` 483 | * `node srv/npm-github.js --seneca.options.tag=npm --seneca.log=type:act --seneca.options.debug.short_logs=true --seneca.options.plugin.github.token=YOUR_GITHUB_TOKEN` 484 | * `node srv/update-dev.js --seneca.options.tag=update --seneca.log=type:act --seneca.options.debug.short_logs=true --seneca.options.plugin.npm_update.task=registry_subscribe` 485 | * These logging options add a filter to show only actions, and also shorten the logs so they are easier to see for debuggin. 486 | * Verify functionality: 487 | * Observe the seneca logs to follow the execution of action patterns 488 | * Use the website and API as before. 489 | * Verify that live npm publishes are registered 490 | * Verify that message flow rate charts are generated in grafana 491 | * Build and run the Docker containers, and verify the same functionality 492 | 493 | ### experiments 494 | 495 | * Try stopping and starting services at random. 496 | * Observe how the mesh network dynamically reconfigures the microservice message flows. 497 | * Try running multiple instances of the _search_ service. 498 | * Observe that the _web_ service automatically load balances between the current _search_ services dynamically. 499 | 500 | 501 | ## Contributing 502 | The [NodeZoo org][Org] encourages __open__ and __safe__ participation. 503 | 504 | - __[Code of Conduct][Coc]__ 505 | 506 | If you feel you can help in any way, be it with documentation, examples, extra testing, or new 507 | features please get in touch. 508 | 509 | ## License 510 | Copyright (c) 2014-2016, Richard Rodger and other contributors. 511 | Licensed under [MIT][Lic]. 512 | 513 | [Banner]: https://raw.githubusercontent.com/nodezoo/nodezoo-org/master/assets/logo-nodezoo.png 514 | [Sponsor]: http://www.nearform.com/ 515 | [Lead]: https://github.com/rjrodger 516 | [Lic]: ./LICENSE 517 | [Coc]: https://github.com/nodezoo/nodezoo-org/blob/master/CoC.md 518 | [Org]: http://www.nodezoo.com/ 519 | 520 | [nodezoo-system]: https://github.com/nodezoo/nodezoo-system 521 | -------------------------------------------------------------------------------- /docker/level/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:4 2 | ADD . / 3 | RUN npm install 4 | 5 | 6 | # build and create: 7 | # $ docker-machine restart default 8 | # $ docker build -t nodezoo-level . 9 | # $ docker create -v /node_modules/seneca-level-store --name nodezoo-level nodezoo-level /bin/true 10 | 11 | 12 | -------------------------------------------------------------------------------- /docker/level/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "level", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "MIT", 11 | "dependencies": { 12 | "seneca-level-store": "^0.2.3" 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /fuge/all-dev.yml: -------------------------------------------------------------------------------- 1 | redis: 2 | image: redis 3 | ports: 4 | - 6379:6379 5 | elasticsearch: 6 | image: elasticsearch 7 | command: 8 | elasticsearch --network.bind_host=0.0.0.0 --network.publish_host=localhost 9 | ports: 10 | - 9200:9200 11 | - 9300:9300 12 | influx: 13 | image: tutum/influxdb 14 | ports: 15 | - 8086:8086 16 | - 8083:8083 17 | beanstalkd: 18 | image: schickling/beanstalkd 19 | ports: 20 | - 11300:11300 21 | github: 22 | build: ../../nodezoo-github/ 23 | container_name: github 24 | info: 25 | build: ../../nodezoo-info/ 26 | container_name: info 27 | npm: 28 | build: ../../nodezoo-npm/ 29 | container_name: npm 30 | search: 31 | build: ../../nodezoo-search/ 32 | container_name: search 33 | web: 34 | build: ../../nodezoo-web/ 35 | container_name: web 36 | -------------------------------------------------------------------------------- /fuge/compose-dev.yml: -------------------------------------------------------------------------------- 1 | base: 2 | build: ../ 3 | container_name: base 4 | msgstats: 5 | build: ../ 6 | container_name: msgstats 7 | github: 8 | build: ../../nodezoo-github/ 9 | container_name: github 10 | info: 11 | build: ../../nodezoo-info/ 12 | container_name: info 13 | npm: 14 | build: ../../nodezoo-npm/ 15 | container_name: npm 16 | search: 17 | build: ../../nodezoo-search/ 18 | container_name: search 19 | web: 20 | build: ../../nodezoo-web/ 21 | container_name: web 22 | -------------------------------------------------------------------------------- /fuge/fuge-config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | runDocker: false, 3 | proxy: 'docker', 4 | exclude: ['**/node_modules', '**/data', '**/.git', '**/CURRENT', '**/LOG*', '**/MANIFEST*', '**/*.ldb', '**/*.log'], 5 | tail: true, 6 | restartOnError: true, 7 | overrides: { 8 | msgstats: { 9 | run: 'node system/msgstats.js' 10 | }, 11 | base: { 12 | run: 'node system/base-node.js' 13 | }, 14 | github: { 15 | run: 'node srv/github-dev.js --seneca.options.tag=github --seneca.options.debug.short_logs=true --seneca.log=type:act --seneca.options.plugin.github.token=`cat srv/.ignore-token`', 16 | build: 'sh build.sh' 17 | }, 18 | info: { 19 | run: 'node srv/info-dev.js --seneca.options.tag=info --seneca.options.debug.short_logs=true --seneca.log=type:act', 20 | build: 'sh build.sh' 21 | }, 22 | npmupdate: { 23 | run: 'node srv/update-dev.js --seneca.options.tag=update --seneca.options.debug.short_logs=true --seneca.log=type:act', 24 | build: 'npm install' 25 | }, 26 | npm: { 27 | run: 'node srv/npm-dev.js --seneca.options.tag=npm --seneca.options.debug.short_logs=true --seneca.log=type:act', 28 | build: 'npm install' 29 | }, 30 | search: { 31 | run: 'node srv/search-dev.js --seneca.options.tag=search --seneca.options.debug.short_logs=true --seneca.log=type:act', 32 | build: 'npm install' 33 | }, 34 | web: { 35 | run: 'node srv/app-dev.js --seneca.options.tag=web --seneca.log=type:act --seneca.options.debug.short_logs=true', 36 | build: 'npm install && bower install' 37 | } 38 | } 39 | }; 40 | 41 | -------------------------------------------------------------------------------- /fuge/infrastructure.yml: -------------------------------------------------------------------------------- 1 | redis: 2 | image: redis 3 | ports: 4 | - 6379:6379 5 | elasticsearch: 6 | image: elasticsearch 7 | command: 8 | elasticsearch --network.bind_host=0.0.0.0 --network.publish_host=localhost 9 | ports: 10 | - 9200:9200 11 | - 9300:9300 12 | influx: 13 | image: tutum/influxdb 14 | ports: 15 | - 8086:8086 16 | - 8083:8083 17 | beanstalkd: 18 | image: schickling/beanstalkd 19 | ports: 20 | - 11300:11300 21 | 22 | -------------------------------------------------------------------------------- /fuge/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodezoo-fuge", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "dependencies": { 7 | "fuge": "^0.4.3" 8 | }, 9 | "devDependencies": {}, 10 | "scripts": { 11 | "test": "echo \"Error: no test specified\" && exit 1" 12 | }, 13 | "author": "", 14 | "license": "MIT" 15 | } 16 | -------------------------------------------------------------------------------- /iteration.sh: -------------------------------------------------------------------------------- 1 | ITER=${1:-i00} 2 | echo "Moving to iteration:" $ITER 3 | 4 | echo "nodezoo-web " $ITER 5 | cd ../nodezoo-web 6 | git checkout $ITER 7 | 8 | echo "nodezoo-search " $ITER 9 | cd ../nodezoo-search 10 | git checkout $ITER 11 | 12 | echo "nodezoo-info " $ITER 13 | cd ../nodezoo-info 14 | git checkout $ITER 15 | 16 | echo "nodezoo-npm " $ITER 17 | cd ../nodezoo-npm 18 | git checkout $ITER 19 | 20 | echo "nodezoo-github " $ITER 21 | cd ../nodezoo-github 22 | git checkout $ITER 23 | 24 | echo "nodezoo-npm-update " $ITER 25 | cd ../nodezoo-npm-update 26 | git checkout $ITER 27 | 28 | cd ../nodezoo 29 | -------------------------------------------------------------------------------- /system/base-node.js: -------------------------------------------------------------------------------- 1 | 2 | var HOST = process.env.HOST || 'localhost' 3 | 4 | require('seneca')() 5 | .use('mesh',{base:true}) 6 | -------------------------------------------------------------------------------- /system/msgstats.js: -------------------------------------------------------------------------------- 1 | 2 | var HOST = process.env.HOST || 'localhost' 3 | 4 | require('seneca')() 5 | .use('msgstats',{ 6 | udp:{host:HOST}, 7 | collect:true, 8 | //ratios:[['res:part,role:info','req:part,role:info']] 9 | }) 10 | -------------------------------------------------------------------------------- /system/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "system", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "MIT", 11 | "dependencies": { 12 | "seneca": "https://github.com/senecajs/seneca", 13 | "seneca-msgstats": "https://github.com/rjrodger/seneca-msgstats", 14 | "seneca-mesh": "https://github.com/rjrodger/seneca-mesh", 15 | "seneca-balance-client": "https://github.com/rjrodger/seneca-balance-client" 16 | } 17 | } 18 | --------------------------------------------------------------------------------