2016-04-26 22:12:46 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2016-04-27 00:15:31 +02:00
|
|
|
"flag"
|
|
|
|
"log"
|
2016-04-26 22:12:46 +02:00
|
|
|
"os"
|
|
|
|
"os/signal"
|
|
|
|
"syscall"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2016-04-27 00:15:31 +02:00
|
|
|
var (
|
|
|
|
addr = flag.String("addr", ":8000", "`host:port` to listen on")
|
|
|
|
directory = flag.String("directory", "/var/lib/go-aptproxy", "`directory` used for storing packages")
|
|
|
|
)
|
|
|
|
flag.Parse()
|
|
|
|
s, err := NewServer(*addr, *directory)
|
2016-04-26 22:12:46 +02:00
|
|
|
if err != nil {
|
2016-04-27 00:15:31 +02:00
|
|
|
log.Println(err)
|
|
|
|
os.Exit(1)
|
2016-04-26 22:12:46 +02:00
|
|
|
}
|
|
|
|
s.Start()
|
2016-04-27 00:15:31 +02:00
|
|
|
defer s.Stop()
|
|
|
|
log.Println("APT proxy started")
|
2016-04-26 22:12:46 +02:00
|
|
|
c := make(chan os.Signal)
|
|
|
|
signal.Notify(c, syscall.SIGINT)
|
|
|
|
<-c
|
2016-04-27 00:15:31 +02:00
|
|
|
log.Println("APT proxy shut down by signal")
|
2016-04-26 22:12:46 +02:00
|
|
|
}
|