1.1.0 • Published 7 years ago

weblab-cli v1.1.0

Weekly downloads
1
License
MIT
Repository
-
Last release
7 years ago

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.

  1. Install via npm:

    $ npm install -g weblab-cli
  2. 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
  3. 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
  4. 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
  5. Inspect logs

    $ wl logs <container-id>
  6. Remove a container

    $ wl rm <container-id>
  7. 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
  8. 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

  1. Realtime log streaming (scheduled for January 2017)

    $ wl logs -f <container-id>
  2. 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

js-standard-style

$ 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>