Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/anowell/servur-ruby
Runs arbitrary ruby libraries behind a simple web server
https://github.com/anowell/servur-ruby
Last synced: about 1 month ago
JSON representation
Runs arbitrary ruby libraries behind a simple web server
- Host: GitHub
- URL: https://github.com/anowell/servur-ruby
- Owner: anowell
- Created: 2015-02-08T18:37:50.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-02-16T07:38:31.000Z (almost 10 years ago)
- Last Synced: 2023-04-09T06:14:33.723Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 156 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# servur-ruby
Proof-of-concept ruby runner for [servur](https://github.com/anowell/servur)# Basic idea
- Servur is a simple web service in a container that takes data POSTed to /data and hands it to a "runner" as stdin
- arunner.rb is a ruby implementation of a "runner" that does some basic transformation of stdin data and calls any arbitrary ruby "executor" with it
- A ruby "executor" is any class that implements `self.execute(input)`
- the filename should currently be the snake_case name of the class which should be CamelCased
- `input` is currently a ruby Hash for JSON data, otherwise simply a raw string# Usage
To run the [anowell/servur-ruby](https://registry.hub.docker.com/u/anowell/servur-ruby/) docker image, you must bind mount an executor to /home/arunner/executor/ and set EXEC_NAME
$ export EXEC_NAME=count_by_letter
$ docker run -p 8080:8080 -e EXEC_NAME -v `pwd`/examples/$EXEC_NAME:/home/arunner/executor:ro anowell/servur-ruby
$ curl -s localhost:8080/data -XPOST -d"hello world"
/bin/arunner.rb output: ----- Executor Output -----
{"h"=>1, "e"=>1, "l"=>3, "o"=>2, "w"=>1, "r"=>1, "d"=>1}Any dependencies specified in a Gemfile will be installed when the container first starts. See [build_stem_set](examples/build_stem_set) for an example with dependencies.
# Testing standalone
Put an example in the executor directory (relative to cwd), set EXEC_NAME, and pipe data into arunner.rb
$ ln -s examples/count_by_letter executor
$ echo "hello world" | EXEC_NAME="count_by_letter" ./arunner.rb
----- Executor Output -----
{"h"=>1, "e"=>1, "l"=>3, "o"=>2, "w"=>1, "r"=>1, "d"=>1}