Rename and move some things around

This commit is contained in:
Derek Collison
2016-04-20 14:42:42 -07:00
parent 6004a4e528
commit 5bea74c2ed
20 changed files with 56 additions and 78 deletions

View File

@@ -1,5 +1,4 @@
# NATS server
##<img src="logos/nats-server.png" width="300">
[![License][License-Image]][License-Url] [![ReportCard][ReportCard-Image]][ReportCard-Url] [![Build][Build-Status-Image]][Build-Status-Url] [![Release][Release-Image]][Release-Url] [![Coverage][Coverage-Image]][Coverage-Url]
A High Performance [NATS](https://nats.io) Server written in [Go.](http://golang.org)

View File

@@ -1,8 +0,0 @@
FROM google/golang:1.4
MAINTAINER Derek Collison <derek@apcera.com>
RUN CGO_ENABLED=0 go get -a -ldflags '-s' --installsuffix cgo github.com/apcera/gnatsd
COPY Dockerfile.final /gopath/bin/Dockerfile
CMD docker build -t apcera/gnatsd /gopath/bin

View File

@@ -1,10 +0,0 @@
FROM scratch
MAINTAINER Derek Collison <derek@apcera.com>
ADD gnatsd /gnatsd
CMD []
ENTRYPOINT ["/gnatsd", "-p", "4222", "-m", "8333"]
EXPOSE 4222 8333

View File

@@ -1,8 +0,0 @@
# [Dockerized] (http://www.docker.com) [nats](https://registry.hub.docker.com/_/nats/)
This is deprecated, please use [nats-docker](https://github.com/nats-io/nats-docker)
A docker image for gnatsd. This is created as a single static executable, so there are multiple passes through Docker to first build the static executable and then to package it under an empty (scratch) base image.

View File

@@ -1,5 +0,0 @@
#!/bin/bash
docker build -t apcera/gnatsd_build .
docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):$(which docker) -ti --name gnatsd_build apcera/gnatsd_build
docker rm gnatsd_build
docker rmi apcera/gnatsd_build

View File

@@ -1,11 +0,0 @@
FROM ubuntu:14.04
MAINTAINER Derek Collison <derek@apcera.com>
RUN apt-get update -y && apt-get install --no-install-recommends -y -q curl build-essential ca-certificates git mercurial bzr
RUN mkdir /goroot && curl https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz | tar xvzf - -C /goroot --strip-components=1
RUN mkdir /gopath
ENV GOROOT /goroot
ENV GOPATH /gopath
ENV PATH $PATH:$GOROOT/bin:$GOPATH/bin

View File

@@ -1,3 +0,0 @@
#!/bin/bash
docker build -t nats_dev .

BIN
logos/nats-server.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
logos/nats-server.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

View File

View File

@@ -13,6 +13,8 @@ import (
"strconv"
"sync/atomic"
"time"
"github.com/nats-io/gnatsd/server/pse"
)
// Snapshot this
@@ -462,7 +464,7 @@ func updateUsage(v *Varz) {
var rss, vss int64
var pcpu float64
procUsage(&pcpu, &rss, &vss)
pse.ProcUsage(&pcpu, &rss, &vss)
v.Mem = rss
v.CPU = pcpu

View File

@@ -1,6 +1,6 @@
// Copyright 2015-2016 Apcera Inc. All rights reserved.
package server
package pse
import (
"errors"
@@ -9,7 +9,7 @@ import (
"os/exec"
)
func procUsage(pcpu *float64, rss, vss *int64) error {
func ProcUsage(pcpu *float64, rss, vss *int64) error {
pidStr := fmt.Sprintf("%d", os.Getpid())
out, err := exec.Command("ps", "o", "pcpu=,rss=,vsz=", "-p", pidStr).Output()
if err != nil {

View File

@@ -1,6 +1,6 @@
// Copyright 2015 Apcera Inc. All rights reserved.
// Copyright 2015-2016 Apcera Inc. All rights reserved.
package server
package pse
/*
#include <sys/types.h>
@@ -56,7 +56,7 @@ import (
)
// This is a placeholder for now.
func procUsage(pcpu *float64, rss, vss *int64) error {
func ProcUsage(pcpu *float64, rss, vss *int64) error {
var r, v C.uint
var c C.double

View File

@@ -1,6 +1,6 @@
// Copyright 2015 Apcera Inc. All rights reserved.
package server
package pse
import (
"bytes"
@@ -27,7 +27,7 @@ func init() {
procStatFile = fmt.Sprintf("/proc/%d/stat", os.Getpid())
}
func procUsage(pcpu *float64, rss, vss *int64) error {
func ProcUsage(pcpu *float64, rss, vss *int64) error {
contents, err := ioutil.ReadFile(procStatFile)
if err != nil {
return err
@@ -56,3 +56,24 @@ func procUsage(pcpu *float64, rss, vss *int64) error {
return nil
}
// Ascii numbers 0-9
const (
asciiZero = 48
asciiNine = 57
)
// parseInt64 expects decimal positive numbers. We
// return -1 to signal error
func parseInt64(d []byte) (n int64) {
if len(d) == 0 {
return -1
}
for _, dec := range d {
if dec < asciiZero || dec > asciiNine {
return -1
}
n = n*10 + (int64(dec) - asciiZero)
}
return n
}

12
server/pse/pse_solaris.go Normal file
View File

@@ -0,0 +1,12 @@
// Copyright 2015-2016 Apcera Inc. All rights reserved.
package pse
// This is a placeholder for now.
func ProcUsage(pcpu *float64, rss, vss *int64) error {
*pcpu = 0.0
*rss = 0
*vss = 0
return nil
}

View File

@@ -1,6 +1,6 @@
// Copyright 2015 Apcera Inc. All rights reserved.
// Copyright 2015-2016 Apcera Inc. All rights reserved.
package server
package pse
import (
"fmt"
@@ -29,7 +29,7 @@ func TestPSEmulation(t *testing.T) {
psVss *= 1024 // 1k blocks, want bytes.
// Our internal version
procUsage(&pcpu, &rss, &vss)
ProcUsage(&pcpu, &rss, &vss)
if pcpu != psPcpu {
delta := int64(pcpu - psPcpu)

View File

@@ -1,16 +1,16 @@
// Copyright 2015-2016 Apcera Inc. All rights reserved.
package server
package pse
import (
"errors"
"fmt"
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
"sync"
"path/filepath"
)
// cache the image name to optimize repeated calls
@@ -112,7 +112,7 @@ func getProcessImageName() (name string) {
// If there is more than one instance, "#<instancecount>" is appended to
// the image name. Wildcard filters are supported, but result in a very
// complex data set to parse.
func procUsage(pcpu *float64, rss, vss *int64) error {
func ProcUsage(pcpu *float64, rss, vss *int64) error {
var ppid int = -1
imageLock.Lock()

View File

@@ -1,6 +1,7 @@
// Copyright 2016 Apcera Inc. All rights reserved.
// +build win
package server
package pse
import (
"fmt"

View File

@@ -1,12 +0,0 @@
// Copyright 2015 Apcera Inc. All rights reserved.
package server
// This is a placeholder for now.
func procUsage(pcpu *float64, rss, vss *int64) error {
*pcpu = 0.0
*rss = 0
*vss = 0
return nil
}

View File

@@ -162,7 +162,7 @@ func PrintAndDie(msg string) {
// PrintServerAndExit will print our version and exit.
func PrintServerAndExit() {
fmt.Printf("gnatsd version %s\n", VERSION)
fmt.Printf("nats-server version %s\n", VERSION)
os.Exit(0)
}
@@ -201,7 +201,7 @@ func (s *Server) logPid() {
// Start up the server, this will block.
// Start via a Go routine if needed.
func (s *Server) Start() {
Noticef("Starting gnatsd version %s", VERSION)
Noticef("Starting nats-server version %s", VERSION)
Debugf("Go build version %s", s.info.GoVersion)
s.running = true
@@ -319,8 +319,8 @@ func (s *Server) AcceptLoop() {
Noticef("TLS required for client connections")
}
Debugf("server id is %s", s.info.ID)
Noticef("server is ready")
Debugf("Server id is %s", s.info.ID)
Noticef("Server is ready")
// Setup state that can enable shutdown
s.mu.Lock()