Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/whoan/servify
Run any command as a service
https://github.com/whoan/servify
hacktoberfest
Last synced: 20 days ago
JSON representation
Run any command as a service
- Host: GitHub
- URL: https://github.com/whoan/servify
- Owner: whoan
- License: mit
- Created: 2019-12-16T02:34:45.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-23T16:50:34.000Z (over 4 years ago)
- Last Synced: 2024-10-26T12:36:09.035Z (2 months ago)
- Topics: hacktoberfest
- Language: Rust
- Homepage:
- Size: 59.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Servify
Run any command as a service.
## Installation
```bash
# install from the latest commit
cargo install --git https://github.com/whoan/servify.git --branch master
```## Usage
```bash
servify -h
``````
USAGE:
servify [FLAGS] [OPTIONS]FLAGS:
-b, --base64 Decodes payload in Base64
-h, --help Prints help information
-V, --version Prints version informationOPTIONS:
-m, --method HTTP method for the service (default: GET)
-p, --port port for the service (default: 8080)
-u, --uri URI for the service (default: /)ARGS:
Command to be called as a service
```## Examples
Run this in a terminal:
```bash
servify 'echo Hello World'
```
```
Command: echo "Hello World"
Service: GET http://0.0.0.0:8080/
```And this in another terminal:
```bash
curl http://0.0.0.0:8080/
```
```
{"status":0,"stderr":"","stdout":"Hello World\n"}
```### Use payload to provide content (as a file) for the command
Write some information on **data** field of JSON payload, and the content will be written to a file and appended to the command:
```bash
servify -m POST 'sed s/World/Mars/'
```
```
Command: sed "s/World/Mars/"
Service: POST http://0.0.0.0:8080/
```In another terminal:
```bash
curl http://0.0.0.0:8080/ -H Content-Type:application/json -d"{\"data\": \"Hello World\"}"
```
```
{"status":0,"stderr":"","stdout":"Hello Mars"}
```### Provide data as Base64
If you need to provide binary or "complex" (in terms of escape characters) data, you can insert it as base 64 in the payload, and use the switch `-b/--base64` to notify servify that should decode the data in advance:
```bash
servify -m POST --base64 'sed s/World/Mars/'
```
```
Command: sed "s/World/Mars/"
Service: POST http://0.0.0.0:8080/
```In another terminal:
```bash
curl http://0.0.0.0:8080/ -H Content-Type:application/json -d"{\"data\": \"$(base64 -w0 <<<"Hello World")\"}"
```
```
{"status":0,"stderr":"","stdout":"Hello Mars\n"}
```## TODO
- Learn Rust and make the code better
## License
[MIT](https://github.com/whoan/servify/blob/master/LICENSE)