Giter VIP home page Giter VIP logo

shell2http's Introduction

shell2http

Go Reference Go build status Coverage Status Report Card Github Releases Docker Pulls Homebrew formula exists

shell2http logo

HTTP-server designed to execute shell commands. It is suitable for development, prototyping or remote control, facilitates rapid iteration and testing of shell-based functionalities. Easy to set up using just two command-line arguments: URL-path and shell command. Next, when an HTTP request is made for the specified path, the stdout of the shell script will be returned, that's all.

Usage

shell2http [options] /path "shell command" /path2 "shell command2" ...
options:
    -host="host"      : host IP for http server (default bind to all interfaces)
    -port=NNNN        : port for http server, 0 - to receive a random port (default 8080)
    -form             : parse query into environment vars, handle uploaded files
    -form-check       : regexp for check form fields (pass only vars that match the regexp)
    -cgi              : run scripts in CGI-mode:
                        - set environment variables with HTTP-request information
                        - write POST|PUT|PATCH-data to script STDIN (if is not set -form)
                        - parse headers from script (eg: "Location: URL\n\n")
    -export-vars=var  : export environment vars ("VAR1,VAR2,...")
                        by default export PATH, HOME, LANG, USER, TMPDIR
    -export-all-vars  : export all current environment vars
    -no-index         : don't generate index page
    -add-exit         : add /exit command
    -log=filename     : log filename, default - STDOUT
    -shell="shell"    : shell for execute command, "" - without shell (default "sh")
    -cache=N          : caching command out for N seconds
    -one-thread       : run each shell command in one thread
    -show-errors      : show the standard output even if the command exits with a non-zero exit code
    -include-stderr   : include stderr to output (default is stdout only)
    -500              : return 500 error if shell exit code != 0
    -cert=cert.pem    : SSL certificate path (if specified -cert/-key options - run https server)
    -key=key.pem      : SSL private key path
    -basic-auth=""    : setup HTTP Basic Authentication ("user_name:password"), can be used several times
    -timeout=N        : set timeout for execute shell command (in seconds)
    -no-log-timestamp : log output without timestamps
    -version
    -help

In the -form mode, variables are available for shell scripts:

  • $v_NNN -- data from query parameter with name "NNN" (example: http://localhost:8080/path?NNN=123)
  • $filepath_ID -- uploaded file path, ID - id from <input type=file name=ID>, temporary uploaded file will be automatically deleted
  • $filename_ID -- uploaded file name from browser

With -form-check option you can specify the regular expression for checking the form fields. For example, if you want to allow only variables that contain the only digits, you can specify the following option: -form-check='^[0-9]+$'. Then only requests like http://localhost:8080/path?NNN=123 will be produce variable $v_NNN.

To setup multiple auth users, you can specify the -basic-auth option multiple times. The credentials for basic authentication may also be provided via the SH_BASIC_AUTH environment variable. You can specify the preferred HTTP-method (via METHOD: prefix for path): shell2http GET:/date date

Install

MacOS:

brew install msoap/tools/shell2http
# update:
brew upgrade shell2http

Download binaries from: releases (MacOS/Linux/Windows/RaspberryPi)

For Docker users, availeble tags see in Docker Hub:

docker pull msoap/shell2http

Using snap (Ubuntu or any Linux distribution with snap):

# install stable version:
sudo snap install shell2http

# install the latest version:
sudo snap install --edge shell2http

# update
sudo snap refresh shell2http

Notice: the snap-package has its own sandbox with the /bin, /usr/bin directories which are not equal to system-wide PATH directories and commands may not work as expected or not work at all.

Build from source (minimum Go version is 1.12):

go install github.com/msoap/shell2http@latest
# set link to your PATH if needed:
ln -s $(go env GOPATH)/bin/shell2http ~/bin/shell2http

Compile for MIPS CPU (for example, for some WiFi routers like Asus):

GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -trimpath -ldflags="-w -s" -o shell2http .

Examples

shell2http /top "top -l 1 | head -10"
shell2http /date date /ps "ps aux"
shell2http -export-all-vars /env 'printenv | sort' /env/path 'echo $PATH' /env/gopath 'echo $GOPATH'
shell2http -export-all-vars /shell_vars_json 'perl -MJSON -E "say to_json(\%ENV)"'
shell2http -export-vars=GOPATH /get 'echo $GOPATH'
HTML calendar for current year
shell2http /cal_html 'echo "<html><body><h1>Calendar</h1>Date: <b>$(date)</b><br><pre>$(cal $(date +%Y))</pre></body></html>"'
Get URL parameters (http://localhost:8080/form?from=10&to=100)
shell2http -form /form 'echo $v_from, $v_to'
CGI scripts
shell2http -cgi /user_agent 'echo $HTTP_USER_AGENT'
shell2http -cgi /set 'touch file; echo "Location: /another_path\n"' # redirect
shell2http -cgi /404 'echo "Status: 404"; echo; echo "404 page"' # custom HTTP code
Upload file
shell2http -form \
    GET:/form 'echo "<html><body><form method=POST action=/file enctype=multipart/form-data><input type=file name=uplfile><input type=submit></form>"' \
    POST:/file 'cat $filepath_uplfile > uploaded_file.dat; echo Ok'

Testing upload file with curl:

curl -i -F uplfile=@some/file/path 'http://localhost:8080/file'
Simple http-proxy server (for logging all URLs) Setup proxy as "http://localhost:8080/"
shell2http -log=/dev/null -cgi / 'echo $REQUEST_URI 1>&2; [ "$REQUEST_METHOD" == "POST" ] && post_param="-d@-"; curl -sL $post_param "$REQUEST_URI" -A "$HTTP_USER_AGENT"'
Test slow connection (http://localhost:8080/slow?duration=10)
shell2http -form /slow 'sleep ${v_duration:-1}; echo "sleep ${v_duration:-1} seconds"'
Proxy with cache in files (for debug with production API with rate limit) get `http://api.url/` as `http://localhost:8080/get?url=http://api.url/`
shell2http -form \
    /form 'echo "<html><form action=/get>URL: <input name=url><input type=submit>"' \
    /get 'MD5=$(printf "%s" $v_url | md5); cat cache_$MD5 || (curl -sL $v_url | tee cache_$MD5)'
Remote sound volume control (Mac OS)
shell2http /get  'osascript -e "output volume of (get volume settings)"' \
           /up   'osascript -e "set volume output volume (($(osascript -e "output volume of (get volume settings)")+10))"' \
           /down 'osascript -e "set volume output volume (($(osascript -e "output volume of (get volume settings)")-10))"'
Remote control for Vox.app player (Mac OS)
shell2http /play_pause 'osascript -e "tell application \"Vox\" to playpause" && echo ok' \
           /get_info 'osascript -e "tell application \"Vox\"" -e "\"Artist: \" & artist & \"\n\" & \"Album: \" & album & \"\n\" & \"Track: \" & track" -e "end tell"'
Get four random OS X wallpapers
shell2http /img 'cat "$(ls "/Library/Desktop Pictures/"*.jpg | ruby -e "puts STDIN.readlines.shuffle[0]")"' \
           /wallpapers 'echo "<html><h3>OS X Wallpapers</h3>"; seq 4 | xargs -I@ echo "<img src=/img?@ width=500>"'
Mock service with JSON API
curl "http://some-service/v1/call1" > 1.json
shell2http -cgi /call1 'cat 1.json' /call2 'echo "Content-Type: application/json\n"; echo "{\"error\": \"ok\"}"'
Windows example

Returns value of var for run in Windows cmd (http://localhost:8080/test?var=value123)

shell2http.exe -form /test "echo %v_var%"
With HTTP headers

Send custom HTTP headers:

shell2http -cgi / 'echo "Content-Type: application/javascript\n"; echo "{\"error\": \"ok\"}"'

On Windows:

shell2http.exe -cgi / "echo Content-Type: application/javascript& echo.& echo body"

More examples ...

Run from Docker-container

Example of test.Dockerfile for server for get current date:

FROM msoap/shell2http
# may be install some alpine packages:
# RUN apk add --no-cache ...
CMD ["/date", "date"]

Build and run container:

docker build -f test.Dockerfile -t date-server .
docker run --rm -p 8080:8080 date-server

SSL

Run https server:

shell2http -cert=./cert.pem -key=./key.pem ...

Generate self-signed certificate:

go run $(go env GOROOT)/src/crypto/tls/generate_cert.go -host localhost

See also

  • Create Telegram bot from command-line - shell2telegram
  • A http daemon for local development - devd
  • Turn any program that uses STDIN/STDOUT into a WebSocket server - websocketd
  • The same tool configurable via JSON - webhook

shell2http's People

Contributors

aaawuanjun avatar free6om avatar msoap avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

shell2http's Issues

quotes are messed up

Hi,

I have a script that fails and that's ok, I'm getting following:

/bin/mkdir: cannot create directory ‘/a/b/c’: No such file or directory
/bin/ln: failed to create symbolic link ‘/c/b’ -> ‘’: No such file or directory
/bin/ln: failed to create symbolic link ‘/c/b’ -> ‘’: No such file or directory

The issue in here are quotes... instead of ASCII shell2http returns unicode's quote (U+2019) what is wrong

Is there any quick fix for this?

can't build

ubuntu@ip-172-31-4-243:~$ go build github.com/msoap/shell2http
go/src/github.com/msoap/shell2http/shell2http.go:4:2: cannot find package "context" in any of:
/usr/lib/go-1.6/src/context (from $GOROOT)
/home/ubuntu/go/src/context (from $GOPATH)

Specify HTTP method for each resource

It looks like that the recent version doesn't support registering resources and specifying the allowed HTTP method for each.

For example:

POST /run/command - to execute
GET /run/command - to get the status

Inconsistent permissions on shell command

When running the program like so

shell2http -port=80 / "tail /root/server/logs/logfile.log"

it gives the following output when a request is received

tail: cannot open '/root/server/logs/logfile.log' for reading: Permission denied
2020/04/01 13:09:57 exec error:  exit status 1

but the command

tail /root/server/logs/logfile.log

can be executed normally outside shell2http.

OS Ubuntu 18.04
The program is being executed by the root user.
The file and directories and are owned by user and group root.
The permissions are as follows:
root: 700
server: 775
logs: 644
logfile.log: 644

I've managed to make shell2http execute the command by setting permissions 744 on the "logs" folder but I'm confused for the reason that it's working.
From what I understood while searching for the answer, directories must have the "x" permission to allow acessing it's files (StackExchange/AskUbuntu), so theoretically my shell is wrong for letting me access the contents of the logs folder, unless there is something special about the root user.

Shouldn't the 2 situations execute the command in the same way?

It may be that this question is more Ubuntu/Linux than about shell2http, so please let me know if here is the appropriate place for it.

docker: not found

when I'm calling bash scripts, which contains docker command I get an exception:
docker: not found
Note: I've installed shell2https with snap, like:
sudo snap install shell2http

caching command out for NNN seconds should based on uri, not path

with -cache=60 option, any requests like /path?url=xxx will be cached with 60s, but the query argument url varies every single request. I guess the cache is implemented based on the request path, not the uri; this behaves badly, because it should not be cached at this way at all.

Cache bases on request uri may be reasonable.

Show output also for failed tasks?

Using shell2http 1.4 (a fantastic tool - thanks a lot for creating this!) we are observing the following behaviour: that the response for tasks that return a non-zero exit code is simply something like:

exec error: exit status 2

In order to actually see the error message and yet still know that the task has actually failed, we are resorting to something along the lines of:

/my/task '(do_stuff; echo Exit code: $?; exit 0)'

Would this be a good candidate for a command-line flag? Or is there an easier way to achieve the desired result (i.e. having stdout and/or stderr returned even for non-zero exit codes) without the hackery in the example above?

-form doesn't seem to work

Hi,
I really like you implementation. this simple yet powerful shell can really help me.
I'm having trouble with the "-form" option.

no matter what i try the $v_xx doesn't work.

shell2http -form /test "echo $v_xx"
running this with the URL "http://localhost:8080/test?xx=123"
the output I get is "$v_xx"

any ideas ?

How to start shell2http?

Currently my bash script is
#!/bin/bash
PWD=/root
SHELL=/bin/bash
PATH=some path variables
cd $PWD
shell2http -port=80 -export-all-vars and my commands

Well. I actually dont understand how shell2http work with enviroment vars. What does -export-all-vars do?

Reply script with no value

Hi,
Can this be achieved? Let me tell you what is going on here.
I have a script that stays on the screen after executing, i've tried sending it to >dev/null with success but http still waits for response until a timeout is displayed. What i want to do is access the "/command" and the website to reply with no content.
Thanks.

How to use custom custom libraries/tools/packages

Hi there,
Great tool you've made. I am trying to use it with a specific package say jq, or even good old curl. Both are present on my system but missing in shell2http's script contexts. I've check with PATHs but nothinhg there. It seems that everything is running contained, which is nice and secure. How could I install those packages without calling the apt-get in my script (which would be overkill) ?
Thanks fo your help

Ability to disable stdout/stderr timestamps

Instead of the application using timestamps, apply the unix philosophy in applying timestamps to the standard output/error: leave it to another tool instead.

When I just wrap everything in a shell script, I would still like to use uniform date format for my entire shell script, with something like moreutils/ts.
With shell2http doing it's own timestamps I cannot do that right now.

So I propose to introduce a --no-timestamps flag to disable shell2http adding timestamps to it's stdout/stderr.

Passing flags to docker container

Great tool. I'm relatively new to docker and am having trouble passing flags to a container I've built from your image that's running on Ubuntu.

Here is my Dockerfile:
FROM msoap/shell2http
CMD ["-form /date 'date'"]

After building, I run the container with this command:
docker run --rm -p 7777:8080 test-server

I get this error:
flag provided but not defined: -form /date 'date'

Am I missing something super simple? Without the "-from" everything works. Thanks!

exec error: exit status 1

C:\Selva\software\shell2http>shell2http -form /starttest "C:\Selva\software\shell2http\script.bat"
2020/03/02 14:17:56 register: /starttest (C:\Selva\software\shell2http\script.bat)
2020/03/02 14:17:56 register: / (index page)
2020/03/02 14:17:56 listen http://:8080/
2020/03/02 14:18:05 localhost:8080 [::1]:55677 GET /starttest "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.122 Safari/537.36"
2020/03/02 14:18:05 exec error: exit status 1

Getting above error when we tired an api for executing a bat file
http://localhost:8080/starttest

Cannot Set Response Header in Windows

in my Arch Linux environment, i have run.sh with content below:

#!/usr/bin/env bash
export HTML_INDEX="site/index.html"
export MAIN_JS="site/main.js"

shell2http -export-all-vars -cgi -form / "cat $HTML_INDEX" \
/echo 'echo "$v_msg"' \
/call2 'echo "Content-Type: application/json";echo ;echo "{\"error\": \"ok\"}"' \
/main.js 'echo "Content-Type: application/javascript";echo ;cat $MAIN_JS' 

in the script above i can set correct Content-Type response header of the /main.js path. it works correctly in browser.

now, i want to replicate script above in Windows environment (Windows 8.1) with run.bat below:

@echo OFF

set HTML_INDEX=site\index.html
set MAIN_JS=site\main.js
set TYPE=Content-Type: application/javascript

shell2http.exe -cgi / "type %HTML_INDEX%" ^
/main.js "echo %TYPE% & type %MAIN_JS%"

the problem is, the Content-Type not set in Response Header, but included in Response Body output of /main.js

Content-Type: application/javascript
alert('Hello World') <-- content inside `site\main.js`

i've tried adding \n\n and echo. to add newline

/main.js "echo %TYPE%\n\n & type %MAIN_JS%"
/main.js "echo %TYPE% & echo. & type %MAIN_JS%"

the Content-Type always included inside the Response Body.

but of course, if i only using this command below:

/main.js "type %MAIN_JS%"

the main.js script executed by the browser successfully, but with Content-Type: text/plain.

How to make the Response Header setting works in windows?

I receive the error "command not found", but actually exists

When I run this command I get this error message:

shell2http -export-all-vars -shell="bash" -form /unblock-ip "csf -g $v_ip"
[root@acesso ~]# shell2http -export-all-vars -shell="bash" -form /unblock-ip "csf -g $v_ip"
2021/03/17 14:26:29 register: /unblock-ip (csf -g )
2021/03/17 14:26:29 register: / (index page)
2021/03/17 14:26:29 listen http://localhost:8080/
2021/03/17 14:26:31 /unblock-ip - 404
bash: csf: command not found

I can affirm that this command exists.

Crashes on launch on Apple Silicon

When I got my shiny new MacMini with the M1 chip, migration assistant transferred my entire homebrew installation from my Intel mac. Somewhat surprisingly, it almost all "just worked" under Rosetta. The only exception I have found so far is shell2http.

Workaround: Build a native M1 version of go according to the instructions here.
Then in this directory, do:

make build
codesign -s - ./shell2http

Voila!

SSL option

I think SSL option will be great. :-)

Live output / flush

For longer running commands, such as wget or pv with progress indication, is it possible to flush output and make it visible to the webbrowser while running?

Arguments not working

If I have a shell like this "shell_script --help", and started the server like this:
shell2http /testing 'shell_script $v_arg1'

It doesn't work if I run it in my browser like this:
http://localhost:8080/testing?arg1=--help

How to send arguments of the shell script correctly?

Unable to query mysql

Hi,
I am trying to create mysql heartbeat on http using this tool.
So I want to execute something as below:

shell2http /showStatus '/var/lib/snapd/snap/bin/mysql.client --user=root --password=root -h 127.0.0.1 -e "select 1+1"'

I installed sudo snap install --beta mysql as well but couldn't figure out.
Can you please help.
Note: actual database in on same instance.

HTTP status code from Docker containers

Hi @msoap
Thanks for this tool.

I have the same use case described in #51. I followed your solution but I only get 200 response when running it in a Docker container.

docker run --name shell-server --rm -p 8080:8080 shell2http-with-scripts -show-errors -cgi -include-stderr /health './error.sh > /dev/null || echo "Status: 503\n\nError\n"' /ok './ok.sh || echo "Status: 503"'

The response for the above:

curl -v localhost:8080/health
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> GET /health HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.54.0
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: shell2http 1.13
< X-Shell2http-Exit-Code: 0
< Date: Tue, 31 Dec 2019 11:55:39 GMT
< Content-Length: 23
< Content-Type: text/plain; charset=utf-8
< 
Status: 503\n\nError\n
* Connection #0 to host localhost left intact

Do you know why?

Add -shell option

For use another shell:
-shell="bash /c"
-shell="" -- dont use shell, execute command directly

Support socket activation with launchd and systemd

This would allow shell2http to be used with inetd-like scenarios, eg. Systemd Socket activation, or Launchd socket activation.

This is especially useful if you want your application to bind to a privileged port (eg. 80), but don't want the application to run as root, but also don't want to set up a separate proxy process to proxy 80 -> 8080.

So in that case you would have a managing process (like launchd, systemd) open the socket on the privileged port and have it passed to the process instead.

Launchd:
https://en.wikipedia.org/wiki/Launchd#Socket_activation_protocol
https://github.com/sstephenson/launch_socket_server/blob/master/src/launch_socket_server.go

Systemd:
http://0pointer.de/blog/projects/socket-activation.html
https://www.darkcoding.net/software/systemd-socket-activation-in-go/
https://github.com/coreos/go-systemd/tree/master/examples/activation/httpserver

I am open to doing a PR if you would find the idea compatible with shell2http.

Am I supposed to see some sort of output from - shell2http /top "top -l 1 | head -10"

I installed the SNAP on my Ubuntu 20.04

I executed several of the "Examples" for instance:

$ shell2http /top "top -l 1 | head -10"
2020/09/11 11:33:32 register: /top (top -l 1 | head -10)
2020/09/11 11:33:32 register: / (index page)
2020/09/11 11:33:32 listen http://localhost:8080/

Am I supposed to see something more than the above? Maybe I am misunderstanding the use of this tool?

Thanks for any enlightenment.

Brian

HTTP status code

Thank you for this great tool, we use it as health check endpoints for a variety of services. Is it possible to change the HTTP status code from '200' to let's say '500' when executed script returns a exit code other then '0' ? This would allow a health check status to be validated based solely on HTTP status code rather than string output. This would cover certain health check validators that lack string output validation.

can execute powershell on Windows ?

On windows, shell2http -shell="powershell" /shell 'something' returns "loading managed windows powershell failed with error 8009001d" for http request.

Broken parse http-headers from cat file (in CGI mode)

Broken parse http-headers from cat file (in CGI mode).
When linking several javascript files, looks like some of them did not load properly.
For example, js file :

var x = new XMLHttpRequest();
var cowlist;
x.open("GET", "http://localhost:8080/array", true);
x.onload = function (){
    str = x.responseText;
    cowlist = str.split(' ');
}
x.send(null);

did not load at all.

Example run:
shell2http -cgi /script ‘cat script.js’

Is it possible to start a systemctl command ?

Hello,

I get a Failed to connect to bus: No such file or directory when trying to run a systemctl command to grab the status of a service:

$ ./shell2http /test 'systemctl is-active --user --quiet myservice && echo "myservice is active"'

shell2http output:

Failed to connect to bus: No such file or directory
2020/11/21 11:51:49 exec error:  exit status 1

I tried launching shell2http as root and using su in the command but it still fails in the same way.

Is it possible to send back systemctl output ?

Windows: Passed parameters executes differently than hardcoded parameters

Awesome program, but I am having a problem in Windows. I am trying to have shell2http run a console executable that requires parameters and uses libraries (dll) in the same directory as the executable.
If I use the below to start shell2http:
shell2http -form /Test "C:\Test\Test.exe Arg1 Arg2 Arg3"
and
http://localhost:8080/Test
It works fine.

But

If I use the below to start shell2http:
shell2http -form /Test "C:\Test\Text.exe %v_arg1% %v_arg2% %v_arg3%"
and
http://localhost:8080/Test/Text.exe?arg1=Arg1&arg2=Arg2&arg3=Arg3

then I get an error that the library dlls cannot be found (even though C:\Test is in the PATH environment variable.

Am I doing something wrong?

Thank you for your help!

config "command:" in docker-compose possibel?

HI

i have the following docker-compose file , but don't get multiple commds to run ...

version: '3.7'

networks:
 proxy-net:
   external: true
   
services:
  shell2http_swarm_master:
    image: bpmspace/docker_bpmspace_base:shell2http
    **command: /bin/sh "/app/shell2http -form /date date /ps "ps aux" /form 'echo $v_from, $v_to'"**
    hostname: shell2http_swarm_master
    deploy:
      labels:
        - traefik.enable=true
        - traefik.http.routers.shell2http_swarm_master.rule=Host(`shell2http_swarm_master.bpmspace.net`)
        - traefik.http.services.shell2http_swarm_master-service.loadbalancer.server.port=8080
      mode: replicated
      replicas: 1
      placement:
        constraints:
          - node.role == manager
    networks:
      - proxy-net   

  shell2http_swarm_node:
    image: bpmspace/docker_bpmspace_base:shell2http
    hostname: shell2http_swarm_node
    deploy:
      labels:
        - traefik.enable=true
        - traefik.http.routers.shell2http_swarm_node.rule=Host(`shell2http_swarm_node.bpmspace.net`)
        - traefik.http.services.shell2http_swarm_node-service.loadbalancer.server.port=8080
      mode: replicated
      replicas: 2
      placement:
        constraints:
          - node.role == worker
    networks:
      - proxy-net   

The error messages is " task: non-zero exit (1)"

When I start the service again without the "command" line it works! BUT i only have 1 command "/date" since my Dockerfile is your test.Dockerfile

Do you have any hint how to "add" new commands via compose file? My image is created via GITHUB -> webhooks -> dockerhub ... so it is no option to add all the commands i need in in the Dockerfile and in a DockerSwarm the "build:" in docker-compose is not supported ....

thanks rob

PS when i try to execute the command in the sh of the container it tells me:

/ # ./app/shell2http -form /date date /ps "ps aux" /form 'echo $v_from, $v_to'
2020/01/05 15:30:40 register: /date (date)
2020/01/05 15:30:40 register: /ps (ps aux)
2020/01/05 15:30:40 register: /form (echo $v_from, $v_to)
2020/01/05 15:30:40 register: / (index page)
2020/01/05 15:30:40 listen tcp :8080: bind: address already in use

Any way to detach executed process?

It seems that shell2http waits for any child process that is spawned to finish.
For example if your un script.py that will spawn another child process script2.py and exits, it will still wait for script2.py to finish. Even thou _script.py has exited. I have tried using & and & disown when starting the script it still seems to be attached to the process and every child process.

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.