Coder Social home page Coder Social logo

curassow's Introduction

Curassow

Build Status

Curassow is a Swift Nest HTTP Server. It uses the pre-fork worker model and it's similar to Python's Gunicorn and Ruby's Unicorn.

It exposes a Nest-compatible interface for your application, allowing you to use Curassow with any Nest compatible web frameworks of your choice.

Usage

To use Curassow, you will need to install it via the Swift Package Manager, you can add it to the list of dependencies in your Package.swift:

import PackageDescription

let package = Package(
  name: "HelloWorld",
  dependencies: [
    .Package(url: "https://github.com/kylef/Curassow.git", majorVersion: 0, minor: 3),
  ]
)

Afterwards you can place your web application implementation in Sources and add the runner inside main.swift which exposes a command line tool to run your web application:

import Curassow
import Inquiline


serve { request in
  return Response(.Ok, contentType: "text/plain", body: "Hello World")
}
$ swift build --configuration release

Command Line Interface

Curassow provides you with a command line interface to configure the address you want to listen on and the amount of workers you wish to use.

Setting the workers
$ ./.build/release/HelloWorld --workers 3
[arbiter] Listening on 0.0.0.0:8000
[arbiter] Started worker process 18405
[arbiter] Started worker process 18406
[arbiter] Started worker process 18407
Configuring the address
$ ./.build/release/HelloWorld --bind 127.0.0.1:9000
[arbiter] Listening on 127.0.0.1:9000
Configuring worker timeouts

By default, Curassow will kill and restart workers after 30 seconds if it hasn't responded to the master process.

$ ./.build/release/HelloWorld --timeout 30

FAQ

What platforms does Curassow support?

Curassow supports both Linux and OS X.

Is there any example applications?

Yes, check out the Hello World example.

How can I change the number of workers dynamically?

TTIN and TTOU signals can be sent to the master to increase or decrease the number of workers.

To increase the worker count by one, where $PID is the PID of the master process.

$ kill -TTIN $PID

To decrease the worker count by one:

$ kill -TTOU $PID

Is it ready for production?

Please consult the deployment guide before deploying Curassow to a production environment. It's important to run Curassow behind a HTTP proxy.

License

Curassow is licensed under the BSD license. See LICENSE for more info.

curassow's People

Contributors

kylef avatar artsabintsev avatar neonichu avatar jamonek avatar ahti avatar dorentus avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.