m3ng9i / ran Goto Github PK
View Code? Open in Web Editor NEWa simple static web server written in Go
License: MIT License
a simple static web server written in Go
License: MIT License
Can you have option for running from inetd in wait mode?
Please add sorting by file name so that it's easy to navigate files.
System: Ran is running on HTTP port 8080
It would be useful if the app printed a URL to console when the server starts, so you can copy-and-paste it to your web browser. Some terminals (gnome-terminal I know) even hyperlink URLs.
Listening on http://127.0.0.1:8080
Listening on http://10.254.216.72.:8080
0.1.3还是2016年发布的,可以更新发布下新版本
I'm not exactly sure why yet but I'm getting a 500 here:
2015-10-04 20:20:59.943920 INFO: System: Ran is running on port 8080
2015-10-04 20:21:04.479125 INFO: Access #ac01f8959d04: [Status: 200] [Host: localhost:8080] [IP: 127.0.0.1] [Method: GET] [URL: /] [Referer: ] [UA: XXX] [Size: 1039] [Time: 6.094ms] [Compression: gzip]
2015-10-04 20:21:06.635230 INFO: Access #9092dd72e70d: [Status: 200] [Host: localhost:8080] [IP: 127.0.0.1] [Method: GET] [URL: /Serien/] [Referer: http://localhost:8080/] [UA: XXX] [Size: 724] [Time: 0.720ms] [Compression: gzip]
2015-10-04 20:21:07.766762 INFO: Access #5f397c73db0e: [Status: 200] [Host: localhost:8080] [IP: 127.0.0.1] [Method: GET] [URL: /Serien/The%20Big%20Bang%20Theory/] [Referer: http://localhost:8080/Serien/] [UA: XXX] [Size: 553] [Time: 0.576ms] [Compression: gzip]
2015-10-04 20:21:08.710824 ERROR: #959b9b5b784d: stat /home/max/Videos/Serien/The%20Big%20Bang%20Theory: no such file or directory
2015-10-04 20:21:08.710917 INFO: Access #959b9b5b784d: [Status: 500] [Host: localhost:8080] [IP: 127.0.0.1] [Method: GET] [URL: /Serien/The%20Big%20Bang%20Theory/The%20Big%20Bang%20Theory%20-%20S5/] [Referer: http://localhost:8080/Serien/The%20Big%20Bang%20Theory/] [UA: XXX] [Size: 131] [Time: 0.681ms] [Compression: gzip]
This is the directory structure:
❯ tree -L 1 Serien/The\ Big\ Bang\ Theory
Serien/The Big Bang Theory
├── The Big Bang Theory - S5
│ └── ...files...
└── The Big Bang Theory - S6
└── ...files...
2 directories, 0 files
A scratch docker image containing the binary would be easier to use ran with docker-compose.
Does it support the rewrite? like .htaccess?
If I run RAN in the background how can I stop it or start it again?
The application (ran) throws back error during the initial execution itself on MacOS (Mojave 10.14). I've downloaded the Darwin binary from the GitHub releases page (https://github.com/m3ng9i/ran/releases/download/v0.1.3/ran_darwin_amd64.zip)
Following is the command which I am using to initialize my server on TCP/10000:
shasum /usr/local/bin/ran # 9fc3975769259aedbcdb236ac5e3149d1f2babb1
chmod u+x /usr/local/bin/ran
ran -p 10000 # The exception logs are available in the next paragraph
Pasting the error logs which are throwing in STDOUT (shows immediately after program execution):
fatal error: unexpected signal during runtime execution
[signal 0xb code=0x1 addr=0x14dd58fa3a4 pc=0x118850]
goroutine 1 [running]:
runtime.throw(0x43c760, 0x2a)
D:/my_dev_tools/golang/go1.5.2/src/runtime/panic.go:527 +0x90 fp=0xc82003d8c8 sp=0xc82003d8b0
runtime.sigpanic()
D:/my_dev_tools/golang/go1.5.2/src/runtime/sigpanic_unix.go:12 +0x5a fp=0xc82003d918 sp=0xc82003d8c8
sync.(*Pool).Get(0x5a3df0, 0x0, 0x0)
D:/my_dev_tools/golang/go1.5.2/src/sync/pool.go:101 +0x40 fp=0xc82003d968 sp=0xc82003d918
fmt.newPrinter(0x14629)
D:/my_dev_tools/golang/go1.5.2/src/fmt/print.go:133 +0x27 fp=0xc82003d9a8 sp=0xc82003d968
fmt.Sprintf(0x3d89e0, 0xc, 0xc82003dae8, 0x2, 0x2, 0x0, 0x0)
D:/my_dev_tools/golang/go1.5.2/src/fmt/print.go:202 +0x2b fp=0xc82003d9f8 sp=0xc82003d9a8
main.getListeningAddr(0x0, 0x0, 0x0, 0x0, 0x0)
d:/my_dropbox/Dropbox/program/projects/go_library/src/github.com/m3ng9i/ran/ran.go:80 +0xac8 fp=0xc82003db70 sp=0xc82003d9f8
main.startLog()
d:/my_dropbox/Dropbox/program/projects/go_library/src/github.com/m3ng9i/ran/ran.go:113 +0x54b fp=0xc82003dd30 sp=0xc82003db70
main.main()
d:/my_dropbox/Dropbox/program/projects/go_library/src/github.com/m3ng9i/ran/ran.go:146 +0x2de fp=0xc82003df50 sp=0xc82003dd30
runtime.main()
D:/my_dev_tools/golang/go1.5.2/src/runtime/proc.go:111 +0x2b0 fp=0xc82003dfa0 sp=0xc82003df50
runtime.goexit()
D:/my_dev_tools/golang/go1.5.2/src/runtime/asm_amd64.s:1721 +0x1 fp=0xc82003dfa8 sp=0xc82003dfa0
goroutine 5 [syscall]:
os/signal.loop()
D:/my_dev_tools/golang/go1.5.2/src/os/signal/signal_unix.go:22 +0x18
created by os/signal.init.1
D:/my_dev_tools/golang/go1.5.2/src/os/signal/signal_unix.go:28 +0x37
goroutine 6 [chan receive]:
github.com/m3ng9i/go-utils/log.(*Logger).start.func1(0xc820082080)
d:/my_dropbox/Dropbox/program/projects/go_library/src/github.com/m3ng9i/go-utils/log/log.go:324 +0xb3
created by github.com/m3ng9i/go-utils/log.(*Logger).start
d:/my_dropbox/Dropbox/program/projects/go_library/src/github.com/m3ng9i/go-utils/log/log.go:367 +0x35
goroutine 8 [runnable]:
syscall.Syscall(0x3, 0x3, 0xc8200e6850, 0x1000, 0x11e, 0x0, 0x0)
D:/my_dev_tools/golang/go1.5.2/src/syscall/asm_darwin_amd64.s:16 +0x5
syscall.read(0x3, 0xc8200e6850, 0x1000, 0x1000, 0x1401b2, 0x0, 0x0)
D:/my_dev_tools/golang/go1.5.2/src/syscall/zsyscall_darwin_amd64.go:972 +0x5f
syscall.Read(0x3, 0xc8200e6850, 0x1000, 0x1000, 0x3, 0x0, 0x0)
D:/my_dev_tools/golang/go1.5.2/src/syscall/syscall_unix.go:160 +0x4d
time.readFile(0x3d0920, 0xe, 0x0, 0x0, 0x0, 0x0, 0x0)
D:/my_dev_tools/golang/go1.5.2/src/time/sys_unix.go:34 +0x19b
time.loadZoneFile(0x0, 0x0, 0x3d0920, 0xe, 0x0, 0x0, 0x0)
D:/my_dev_tools/golang/go1.5.2/src/time/zoneinfo_read.go:206 +0x199
time.initLocal()
D:/my_dev_tools/golang/go1.5.2/src/time/zoneinfo_unix.go:59 +0x77
sync.(*Once).Do(0x5c95b0, 0x46c238)
D:/my_dev_tools/golang/go1.5.2/src/sync/once.go:44 +0xe4
time.(*Location).get(0x5a43c0, 0x0)
D:/my_dev_tools/golang/go1.5.2/src/time/zoneinfo.go:76 +0x58
time.Time.locabs(0xe7791f700, 0x0, 0x5a43c0, 0x0, 0x0, 0x0, 0x0)
D:/my_dev_tools/golang/go1.5.2/src/time/time.go:270 +0x131
time.Time.AppendFormat(0xe7791f700, 0x0, 0x5a43c0, 0xc8200e7c20, 0x0, 0x40, 0x4153c0, 0x1a, 0x0, 0x0, ...)
D:/my_dev_tools/golang/go1.5.2/src/time/format.go:438 +0x65
time.Time.Format(0xe7791f700, 0x0, 0x5a43c0, 0x4153c0, 0x1a, 0x0, 0x0)
D:/my_dev_tools/golang/go1.5.2/src/time/format.go:430 +0xf2
github.com/m3ng9i/go-utils/log.(*Logger).msg2bytes(0xc820082380, 0xc82000b560, 0x29, 0xe7791f700, 0x0, 0x5a43c0, 0x2, 0x0, 0x0, 0x0)
d:/my_dropbox/Dropbox/program/projects/go_library/src/github.com/m3ng9i/go-utils/log/log.go:437 +0xec
github.com/m3ng9i/go-utils/log.(*Logger).start.func1(0xc820082380)
d:/my_dropbox/Dropbox/program/projects/go_library/src/github.com/m3ng9i/go-utils/log/log.go:364 +0x80f
created by github.com/m3ng9i/go-utils/log.(*Logger).start
d:/my_dropbox/Dropbox/program/projects/go_library/src/github.com/m3ng9i/go-utils/log/log.go:367 +0x35
goroutine 9 [select, locked to thread]:
runtime.gopark(0x46bfe8, 0xc820029728, 0x3cd670, 0x6, 0x18, 0x2)
D:/my_dev_tools/golang/go1.5.2/src/runtime/proc.go:185 +0x163
runtime.selectgoImpl(0xc820029728, 0x0, 0x18)
D:/my_dev_tools/golang/go1.5.2/src/runtime/select.go:392 +0xa64
runtime.selectgo(0xc820029728)
D:/my_dev_tools/golang/go1.5.2/src/runtime/select.go:212 +0x12
runtime.ensureSigM.func1()
D:/my_dev_tools/golang/go1.5.2/src/runtime/signal1_unix.go:227 +0x323
runtime.goexit()
D:/my_dev_tools/golang/go1.5.2/src/runtime/asm_amd64.s:1721 +0x1
goroutine 10 [chan receive]:
main.catchSignal.func1(0xc8200163c0)
d:/my_dropbox/Dropbox/program/projects/go_library/src/github.com/m3ng9i/ran/ran.go:19 +0x68
created by main.catchSignal
d:/my_dropbox/Dropbox/program/projects/go_library/src/github.com/m3ng9i/ran/ran.go:24 +0x242
This happens on install:
$ go get -u github.com/m3ng9i/ran
# github.com/m3ng9i/ran/server
D:\IT\Go\src\github.com\m3ng9i\ran\server\server.go:199: undefined: "github.com/m3ng9i/go-utils/http".BasicAuth
In some cases, knowing that a port will available is difficult.
Rather than guessing, it would be good to allow '--port=0' to let the kernel pick a port and have ran use that.
conveying the port to a consumer would be helpful but not entirely necessary. then you could do something like:
ran --port=0 my.dir > my.log 2>&1 &
url=""
while [ -z "$url" ]; do
url=$(awk '$0 ~ /Listening on/ { print $7}' my.log)
done
echo "listening on $url"
Please add Start/Stop as daemon
This project doesn't have a license yet. Can you please add one?
MIT, Apache or something as unrestrictive as possible (as far as it works with the licenses of the dependencies, of course) would be great to have :)
OS: Linux (Ubuntu 18.04)
Some of my files have special characters like '
or "
. Files and directories with these special characters display the 404 page instead of the file.
For some JS frameworks all paths should be redirected to /
See #4 here
https://routify.now.sh/docs/install
Hi,
I wanted to replace my own tiny GO Http server with ran. Unfortunately, I can't get it working on heroku. Ran works nicely on my local Ubuntu 20.04 machine. I found two problems, the first one I could help myself and the second one is still unresolved.
Problem 1: ran doesn't work in an alpine container. I needed to recompile the sources with the command line
CGO_ENABLED=0 go build .
Problem 2: now that this new ran binary works in an alpine container, I deployed it to Heroku, but I get the following log messages:
heroku[web.1]: Starting process with command `/ran -r /web -p \$\{PORT\} -b 0.0.0.0`
app[web.1]: 2020-07-15 17:52:27.117366 INFO: System: Ran is running on HTTP port 5101
app[web.1]: 2020-07-15 17:52:27.117370 INFO: System: Listening on http://0.0.0.0:5101
heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
heroku[web.1]: Stopping process with SIGKILL
eroku[web.1]: Process exited with status 137
My Dockerfile is as follows:
FROM alpine
COPY ran/ran /ran
WORKDIR /web
COPY dist /web
ENTRYPOINT [ "/ran", "-r", "/web", "-p", "${PORT}", "-b", "0.0.0.0" ]
The ${PORT} is neccessary, because Heroku is setting this env var each time to a different port number.
I know that it's important to use "0.0.0.0" instead of "localhost" and you have to use the given port. Both settings are correct from my point of view.
Do you have an idea, why Heroku can't access ran?
Best regards
Support arguments like "--follow-symlink" in static-server in nodejs
Is it possible to embed letsencrypt certificate creation and also assign domain name like www.example.com?
The server will serve files outside the specified root.
Version: v0.1.5
OS: Windows 10
Binary: Precompiled Windows x64 v0.1.5 downloaded on the release pages
Steps to reproduce on Windows (did not test any other OS):
When using -listdir=true its also possible to browse folders and navigate around.
The 404 (and 401) error page should be "hidden" from sight. This means returning a 404 when someone requests the real URL. Say I run something lik this:
ran -r www/ -404=/404.html
a) A request to /nonexistent
renders content of 404.html and returns a status code of 404.
b) A request to /404.html
renders the same page, but with a status code of 200.
The second use case should return a status code of 404, as this file should not be addressable directly. When using nginx, I usually use a location
block with the keyword internal
to force a 404.
First, thanks for your hardwork.
Can you support index file human-readable size?
hey ... everything is okay but ...
first of all: binary listening on all interface, please add option for change this. i can change this from source code but its nicer to have a option for doing this.
and more important: server overloading when clients establishing to many connections, cpu goes on 100% and load average above 5 on single core server :|
please add option to limit number of client connections and clients request/per-time
环境:Windows
D:\Download\SS>Ran.exe -v
Version: v0.1.3, Branch: master, Build: ff83877, Build time: 2016-08-08 18:43 +0800
D:\Download\SS>Ran.exe -l ture -p 80
2016-12-27 08:56:42.789341 INFO: System: Ran is running on HTTP port 8080
2016-12-27 08:56:42.792345 INFO: System: Listening on http://192.168.1.3:8080
2016-12-27 08:56:42.792345 INFO: System: Listening on http://127.0.0.1:8080
2016-12-27 08:56:43.647785 INFO: System: Catch signal: interrupt, Ran is going to shutdown
D:\Download\SS>Ran.exe -p 80 -l ture
2016-12-27 08:56:59.462496 INFO: System: Ran is running on HTTP port 80
2016-12-27 08:56:59.465500 INFO: System: Listening on http://192.168.1.3:80
2016-12-27 08:56:59.465500 INFO: System: Listening on http://127.0.0.1:80
2016-12-27 08:57:01.997015 INFO: System: Catch signal: interrupt, Ran is going to shutdown
Listen on the given net interface of ip address is a better choice.
current the service url start with the root /
, will it support a custom url prefix?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.