Browse Source

new package

master
parent
commit
f96eb977d0
  1. 64
      tile38/rc.tile38
  2. 76
      tile38/tile38.patch
  3. 122
      tile38/tile38.spec

64
tile38/rc.tile38

@ -0,0 +1,64 @@
#!@l_prefix@/bin/openpkg rc
##
## rc.tile38 -- Run-Commands
##
%config
tile38_enable="$openpkg_rc_def"
tile38_flags="-h 127.0.0.1 -p 9851"
tile38_log_prolog="true"
tile38_log_epilog="true"
tile38_log_numfiles="10"
tile38_log_minsize="1M"
tile38_log_complevel="9"
%common
tile38_datdir="@l_prefix@/var/tile38/db"
tile38_pidfile="@l_prefix@/var/tile38/run/tile38.pid"
tile38_logfile="@l_prefix@/var/tile38/log/tile38.log"
tile38_signal () {
[ -f $tile38_pidfile ] && kill -$1 `cat $tile38_pidfile`
}
%status -u @l_rusr@ -o
tile38_usable="unknown"
tile38_active="no"
rcService tile38 enable yes && \
tile38_signal 0 && tile38_active="yes"
echo "tile38_enable=\"$tile38_enable\""
echo "tile38_usable=\"$tile38_usable\""
echo "tile38_active=\"$tile38_active\""
%start -u @l_rusr@
rcService tile38 enable yes || exit 0
rcService tile38 active yes && exit 0
( GOMAXPROCS=32
export GOMAXPROCS
nohup @l_prefix@/sbin/tile38-server \
-d $tile38_datdir \
$tile38_flags \
</dev/null >>$tile38_logfile 2>&1 &
echo $! >$tile38_pidfile
) >/dev/null 2>&1
%stop -u @l_rusr@
rcService tile38 enable yes || exit 0
rcService tile38 active no && exit 0
tile38_signal TERM
sleep 2
rm -f $tile38_pidfile >/dev/null 2>&1 || true
%restart -u @l_rusr@
rcService tile38 enable yes || exit 0
rcService tile38 active no && exit 0
rc tile38 stop start
%daily -u @l_rusr@
rcService tile38 enable yes || exit 0
shtool rotate -f \
-n ${tile38_log_numfiles} -s ${tile38_log_minsize} -d \
-z ${tile38_log_complevel} -m 664 -o @l_rusr@ -g @l_rgrp@ \
-P "${tile38_log_prolog}" \
-E "${tile38_log_epilog}; rc tile38 restart" \
$tile38_logfile

76
tile38/tile38.patch

@ -0,0 +1,76 @@
Index: cmd/tile38-server/main.go
--- cmd/tile38-server/main.go.orig 2016-03-05 13:08:02.000000000 +0100
+++ cmd/tile38-server/main.go 2016-03-05 13:18:59.712581631 +0100
@@ -17,6 +17,7 @@
var (
dir string
+ host string
port int
verbose bool
veryVerbose bool
@@ -25,6 +26,7 @@
)
func main() {
+ flag.StringVar(&host, "h", "127.0.0.1", "The listening host for communication.")
flag.IntVar(&port, "p", 9851, "The listening port for communication.")
flag.StringVar(&dir, "d", "data", "The data directory.")
flag.BoolVar(&verbose, "v", false, "Enable verbose logging.")
@@ -59,7 +61,7 @@
|_______|_______|
`+"\n", core.Version, core.GitSHA, strconv.IntSize, runtime.GOARCH, runtime.GOOS, port, os.Getpid())
- if err := controller.ListenAndServe(port, dir); err != nil {
+ if err := controller.ListenAndServe(host, port, dir); err != nil {
log.Fatal(err)
}
}
Index: controller/controller.go
--- controller/controller.go.orig 2016-03-05 13:08:02.000000000 +0100
+++ controller/controller.go 2016-03-05 13:18:09.792727850 +0100
@@ -52,6 +52,7 @@
// Controller is a tile38 controller
type Controller struct {
mu sync.RWMutex
+ host string
port int
f *os.File
cols *btree.BTree // use both tree and map. provide ordering.
@@ -80,9 +81,10 @@
}
// ListenAndServe starts a new tile38 server
-func ListenAndServe(port int, dir string) error {
+func ListenAndServe(host string, port int, dir string) error {
log.Infof("Server started, Tile38 version %s, git %s", core.Version, core.GitSHA)
c := &Controller{
+ host: host,
port: port,
dir: dir,
cols: btree.New(16),
@@ -127,7 +129,7 @@
}
return nil
}
- return server.ListenAndServe(port, handler)
+ return server.ListenAndServe(host, port, handler)
}
func (c *Controller) setCol(key string, col *collection.Collection) {
Index: server/server.go
--- server/server.go.orig 2016-03-05 13:08:02.000000000 +0100
+++ server/server.go 2016-03-05 13:18:41.413563459 +0100
@@ -20,10 +20,11 @@
// ListenAndServe starts a tile38 server at the specified address.
func ListenAndServe(
+ host string,
port int,
handler func(command []byte, conn net.Conn, rd *bufio.Reader, w io.Writer, websocket bool) error,
) error {
- ln, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
+ ln, err := net.Listen("tcp", fmt.Sprintf("%s:%d", host, port))
if err != nil {
return err
}

122
tile38/tile38.spec

@ -0,0 +1,122 @@
##
## tile38.spec -- OpenPKG RPM Package Specification
## Copyright (c) 2000-2016 OpenPKG Foundation e.V. <http://openpkg.net/>
##
## Permission to use, copy, modify, and distribute this software for
## any purpose with or without fee is hereby granted, provided that
## the above copyright notice and this permission notice appear in all
## copies.
##
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
## SUCH DAMAGE.
##
# package information
%define V_tile38_base 20160305
%define V_tile38_snap 20160305
# package information
Name: tile38
Summary: Geolocation Storage Engine
URL: https://github.com/tidwall/tile38
Vendor: Josh Baker
Packager: OpenPKG Foundation e.V.
Distribution: OpenPKG Community
Class: EVAL
Group: Database
License: MIT
Version: %{V_tile38_base}
Release: 20160305
# list of sources
Source0: http://download.openpkg.org/components/versioned/tile38/tile38-%{V_tile38_snap}.tar.xz
Source1: rc.tile38
Patch0: tile38.patch
# build information
BuildPreReq: OpenPKG, openpkg >= 20160101, go
PreReq: OpenPKG, openpkg >= 20160101
%description
Tile38 is an open source (MIT licensed), in-memory geolocation data
store, spatial index, and realtime geofence. It supports a variety
of object types including lat/lon points, bounding boxes, XYZ tiles,
Geohashes, and GeoJSON.
%track
prog tile38 = {
version = %{V_tile38_snap}
url = http://download.openpkg.org/components/versioned/tile38/
regex = tile38-(__VER__)\.tar\.xz
}
%prep
%setup -q -n tile38
%patch -p0 -d src/github.com/tidwall/tile38
%build
# build program
export GOPATH=`pwd`
cd $GOPATH/src/github.com/tidwall/tile38
go build -x -o tile38-cli cmd/tile38-cli/*.go
go build -x -o tile38-server cmd/tile38-server/*.go
%install
# create directory hierarchy
%{l_shtool} mkdir -f -p -m 755 \
$RPM_BUILD_ROOT%{l_prefix}/bin \
$RPM_BUILD_ROOT%{l_prefix}/sbin \
$RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
$RPM_BUILD_ROOT%{l_prefix}/var/tile38/run \
$RPM_BUILD_ROOT%{l_prefix}/var/tile38/log \
$RPM_BUILD_ROOT%{l_prefix}/var/tile38/db
# install program
%{l_shtool} install -c -s -m 755 \
src/github.com/tidwall/tile38/tile38-cli \
$RPM_BUILD_ROOT%{l_prefix}/bin/
%{l_shtool} install -c -s -m 755 \
src/github.com/tidwall/tile38/tile38-server \
$RPM_BUILD_ROOT%{l_prefix}/sbin/
# install run-command script
%{l_shtool} install -c -m 755 %{l_value -s -a} \
%{SOURCE rc.tile38} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
# determine installation files
%{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
%{l_files_std} \
'%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/tile38/*'
%files -f files
%clean
%post
if [ $1 -eq 2 ]; then
# after upgrade, restart service
eval `%{l_rc} tile38 status 2>/dev/null`
[ ".$tile38_active" = .yes ] && %{l_rc} tile38 restart
fi
exit 0
%preun
if [ $1 -eq 0 ]; then
# before erase, stop service and remove log files
%{l_rc} tile38 stop 2>/dev/null
rm -rf $RPM_INSTALL_PREFIX/var/tile38/log/* >/dev/null 2>&1 || true
rm -rf $RPM_INSTALL_PREFIX/var/tile38/run/* >/dev/null 2>&1 || true
rm -rf $RPM_INSTALL_PREFIX/var/tile38/db/* >/dev/null 2>&1 || true
fi
exit 0
Loading…
Cancel
Save