Random port after all #152
Former-commit-id: cac7b9214af0d8f01c98aa8dd8a9cd3d564125cb [formerly 25bf09a073b247ca282796610a4ac3de6f98e6ec] [formerly ba24813e1e5e4fc9105ff6a48018e6d6d6ed3142 [formerly dd3ccec696
]]
Former-commit-id: 79b54956082db4f93d78cb04c48bcab4390c1163 [formerly 6cf6c0f610527cf7664149bd8fcccc22107f8de8]
Former-commit-id: 092e7842602412ef71623865bc32856ba959bbbc
This commit is contained in:
parent
a936d04bfc
commit
3a2ccf6275
|
@ -58,6 +58,8 @@ The `scope`, `allowCommands`, `allowEdit`, `allowNew` and `commands` options are
|
||||||
Otherwise, you may not want to use a configuration file, which can be done using the following flags:
|
Otherwise, you may not want to use a configuration file, which can be done using the following flags:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
-address string
|
||||||
|
Address to listen to (default is all of them)
|
||||||
-allow-commands
|
-allow-commands
|
||||||
Default allow commands option (default true)
|
Default allow commands option (default true)
|
||||||
-allow-edit
|
-allow-edit
|
||||||
|
@ -69,9 +71,9 @@ Otherwise, you may not want to use a configuration file, which can be done using
|
||||||
-database string
|
-database string
|
||||||
Database path (default "./filemanager.db")
|
Database path (default "./filemanager.db")
|
||||||
-port string
|
-port string
|
||||||
HTTP Port (default "80")
|
HTTP Port (default is random)
|
||||||
-scope string
|
-scope string
|
||||||
Defualt scope for new users (default ".")
|
Default scope for new users (default ".")
|
||||||
```
|
```
|
||||||
|
|
||||||
# Features
|
# Features
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -27,6 +28,7 @@ type confFile struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
addr string
|
||||||
config string
|
config string
|
||||||
database string
|
database string
|
||||||
scope string
|
scope string
|
||||||
|
@ -39,7 +41,8 @@ var (
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
flag.StringVar(&config, "config", "", "JSON configuration file")
|
flag.StringVar(&config, "config", "", "JSON configuration file")
|
||||||
flag.StringVar(&port, "port", "8080", "HTTP Port")
|
flag.StringVar(&port, "port", "0", "HTTP Port (default is random)")
|
||||||
|
flag.StringVar(&addr, "address", "", "Address to listen to (default is all of them)")
|
||||||
flag.StringVar(&database, "database", "./filemanager.db", "Database path")
|
flag.StringVar(&database, "database", "./filemanager.db", "Database path")
|
||||||
flag.StringVar(&scope, "scope", ".", "Default scope for new users")
|
flag.StringVar(&scope, "scope", ".", "Default scope for new users")
|
||||||
flag.StringVar(&commands, "commands", "git svn hg", "Space separated commands available for new users")
|
flag.StringVar(&commands, "commands", "git svn hg", "Space separated commands available for new users")
|
||||||
|
@ -72,8 +75,13 @@ func main() {
|
||||||
fm.SetBaseURL("/")
|
fm.SetBaseURL("/")
|
||||||
fm.SetPrefixURL("/")
|
fm.SetPrefixURL("/")
|
||||||
|
|
||||||
fmt.Println("Starting filemanager on *:" + port)
|
listener, err := net.Listen("tcp", addr+":"+port)
|
||||||
if err := http.ListenAndServe(":"+port, fm); err != nil {
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("Listening on", listener.Addr().String())
|
||||||
|
if err := http.Serve(listener, fm); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue