Weblab CLI
Weblab – Build applications comprised of microservices that run forever, self-heal and scale as needed. Building scalable fault-tolerant systems has never been easier.
The Weblab CLI it's a command-line tool to interact with Weblab for developing and deploying your serverless microservice architecture.
Contents
Quick Start
Follow the steps below to create and deploy your first serverless microservice in seconds.
-
Install via npm:
$ npm install -g weblab-cli
-
Set-up your credentials
$ weblab register Setup your Weblab Account ------------------------- > Email: cristi@weblab.io > Username: (cristi) > Password: *********** Success: User registration complete.
or if you already have a Weblab account just sign in with your credentials
$ weblab login
-
Deploy a service
In your Weblab microservice folder just run
$ cd µservice $ wl deploy Service: hello-world-1.0.0 Enpoints: GET - https://weblab.io/api/v1/run/cristi/hello-world-1.0.0/ Uploading: ... success
-
List your services
$ wl ls CONTAINER | MICROSERVICE | STATE | STATUS 3a377aea233d | hello-world-1.0.0 | running | Up 2 hours 3a48678fce52 | hal-1.0.0 | running | Up 2 hours 8bd1f4577575 | container-events-0.0.2 | running | Up 3 weeks 1c260895c73e | weblab-fb-bot-1.0.0 | running | Up 11 weeks
-
Inspect logs
$ wl logs <container-id>
-
Remove a container
$ wl rm <container-id>
-
Scale your microservice
$ wl deploy -s 2 Service: hello-world-1.0.0 Scale: 2 workers Enpoints: GET - https://weblab.io/api/v1/run/cristi/hello-world-1.0.0/ Uploading: ... success $ wl ls CONTAINER | MICROSERVICE | STATE | STATUS ca5785b7aff2 | hello-world-1.0.0 | running | Up 4 seconds 6b0c33c7f206 | hello-world-1.0.0 | running | Up 4 seconds 3a48678fce52 | hal-1.0.0 | running | Up 3 hours 8bd1f4577575 | container-events-0.0.2 | running | Up 3 weeks 1c260895c73e | weblab-fb-bot-1.0.0 | running | Up 11 weeks
-
Run your microservice on your local machine
$ wl local Service: hello-world-1.0.0 Endpoints: GET - http://localhost:8991/ Server: Started on port 8991
Useful if you want to test your microservice localy before deploying to Weblab.
Examples
Hello World
package.json
{
"name": "hello-world",
"version": "1.0.0",
"main": "index.js"
}
index.js
module.exports = function (req, res) {
res.send('Hello, world!')
}
Upcoming Features
-
Realtime log streaming (scheduled for January 2017)
$ wl logs -f <container-id>
-
Remote debugging (scheduled for February 2017)
Use your favorite IDE (WebStorm / VS Code / etc.) to remote debug your microservice.
Development
Tests
$ npm test
Linter
We're using ESLint with Standard config
$ npm run lint
Unit tests
$ npm run unit
Git Hooks
- pre-commit hook to run linter before every commit
To install it just run in the project root directory:
$ ./tools/hooks/install.sh
If you want to skip the tests when you make a push just use the --no-verify
flag. Example:
$ git commit --no-verify <remote> <branch>