Skip to content

Commit

Permalink
Update version to v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bclswl0827 committed Aug 7, 2024
1 parent b2150f3 commit f0315ab
Show file tree
Hide file tree
Showing 255 changed files with 7,547 additions and 5,491 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Build Docker Image

on:
workflow_dispatch:
push:
tags:
- "*"

env:
REGISTRY: ghcr.io
IMAGE: anyshake/observer

jobs:
build_docker_image:
runs-on: ubuntu-latest

permissions:
packages: write
contents: read

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Login to Registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and Push
uses: docker/build-push-action@v2
with:
push: true
file: ./Dockerfile
tags: ${{ env.REGISTRY }}/${{ env.IMAGE }}:latest

- name: Inspect Image
run: |
docker buildx imagetools inspect \
${{ env.REGISTRY }}/${{ env.IMAGE }}:latest
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ jobs:
if: steps.build_docs.outputs.status == 'success'
run: |
go mod download
cd build
make -j$(nproc)
echo "::set-output name=status::success"
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@ _testmain.go
*.test
*.prof

# AnyShake Observer build files
build/dist*
build/release*
build/dist
frontend/dist
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@

Starting from v2.2.5, all notable changes to this project will be documented in this file.

## v3.0.0

### Breaking Changes

- **Data Protocol**: The AnyShake Explorer data protocol has been entirely refactored. **Please rebuild and flash the firmware of AnyShake Explorer to the latest version.**
- **Configuration File**: The configuration file layout has been completely overhauled. The old configuration file format is no longer supported.
- **SeedLink Server**: The SeedLink service has been temporarily removed and will be re-implemented in a future release.
- **API Endpoints**: Some request and response fields have been modified in API v1. Please refer to the built-in Swagger API documentation for details.

### New Features

- Added support for accessing AnyShake Explorer via a serial-to-Ethernet converter.
- Introduced custom channel prefixes (e.g., HH*, SH*, EH*).
- Added log dumping functionality with multiple output levels.
- Enhanced data processing and storage efficiency.
- Improved the accuracy of reading time from the Internet NTP server.
- Refined component lifecycle management using dependency injection for better module decoupling.
- Implemented an asynchronous message bus to optimize application execution efficiency.
- Established a GraphQL-based routing endpoint in preparation for API v2.
- Dockerized the application for easier and faster deployment.

### Bug Fixes

- Completely resolved the gap issue in MiniSEED records.

## v2.12.5

- Fix gaps in MiniSEED records
Expand Down
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM golang:alpine AS builder

RUN apk update && apk add --no-cache git bash wget curl make npm
WORKDIR /build
RUN git clone --progress https://github.com/anyshake/observer.git ./observer && \
export VERSION=`cat ./observer/VERSION` && \
cd ./observer/frontend/src && \
npm install && \
make && \
cd ../../docs && \
make && \
cd ../cmd && \
go mod tidy && \
go build -ldflags "-s -w -X main.version=$VERSION -X main.release=docker_build" -trimpath -o /tmp/observer *.go

FROM alpine

COPY --from=builder /tmp/observer /usr/bin/observer
RUN chmod 755 /usr/bin/observer && \
mkdir -p /etc/observer

CMD ["observer", "-config=/etc/observer/config.json"]
30 changes: 17 additions & 13 deletions build/Makefile → Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
.PHONY: build clean version run windows
.PHONY: build clean gen docs version run windows

BINARY=observer
VERSION=$(shell cat ../VERSION)
VERSION=$(shell cat ./VERSION)
RELEASE=$(shell date +%Y%m%d%H%M%S)
COMMIT=$(shell git rev-parse --short HEAD)

SRC_DIR=../cmd
DIST_DIR=./dist
ASSETS_DIR=./assets
SRC_DIR=./cmd
DIST_DIR=./build/dist
ASSETS_DIR=./build/assets

BUILD_ARCH=arm arm64 386 amd64 ppc64le riscv64 \
mips mips64le mipsle loong64 s390x
BUILD_ARCH=arm arm64 386 amd64 ppc64le riscv64 loong64 s390x
BUILD_FLAGS=-s -w -X main.version=$(VERSION) \
-X main.release=$(COMMIT)-$(RELEASE)
BUILD_ARGS=-trimpath
Expand All @@ -25,16 +24,21 @@ $(BUILD_ARCH):
@cp -r $(ASSETS_DIR) $(DIST_DIR)/$@

windows:
@echo "Building Windows 32-bit & 64-bit ..."
@mkdir -p $(DIST_DIR)/win32 $(DIST_DIR)/win64
@rm -rf $(DIST_DIR)/win32/* $(DIST_DIR)/win64/*
@CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags="$(BUILD_FLAGS)" \
$(BUILD_ARGS) -o $(DIST_DIR)/win32/$(BINARY).exe $(SRC_DIR)/*.go
@echo "Building Windows 64-bit ..."
@mkdir -p $(DIST_DIR)/win64
@rm -rf $(DIST_DIR)/win64/*
@CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="$(BUILD_FLAGS)" \
$(BUILD_ARGS) -o $(DIST_DIR)/win64/$(BINARY).exe $(SRC_DIR)/*.go
@cp -r $(ASSETS_DIR) $(DIST_DIR)/win32
@cp -r $(ASSETS_DIR) $(DIST_DIR)/win64

gen:
ifeq ($(shell command -v gqlgen 2> /dev/null),)
@echo "Installing gqlgen..."
@go get github.com/99designs/gqlgen
@go install github.com/99designs/gqlgen
endif
@gqlgen generate

version:
@go run $(SRC_DIR)/*.go --version

Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ AnyShake Observer is an open-source, cross-platform software that can be used to

This software is written in Go and TypeScript, which means it can easily port to a variety of OS and CPU architectures, even embedded Linux devices, AnyShake Observer also supports PostgreSQL, MariaDB (MySQL) and SQL Server as seismic data archiving engines.

As of the release of the software documentation, AnyShake has successfully captured more than 40 earthquake events, the furthest captured earthquake event is [M 7.1 - 180 km NNE of Gili Air, Indonesia](https://earthquake.usgs.gov/earthquakes/eventpage/us7000krjx/executive), approximately 4,210 km, by the station located in Chongqing, China.

## Documentation

Please visit [anyshake.org/docs/introduction](https://anyshake.org/docs/introduction) for quick start guide and more information.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.12.5
v3.0.0
10 changes: 4 additions & 6 deletions app/v1/devel/module.go → api/v1/devel/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@ package devel
import (
"net/http"

"github.com/anyshake/observer/app"
v1 "github.com/anyshake/observer/api/v1"
_ "github.com/anyshake/observer/docs"
"github.com/gin-gonic/gin"
swaggerFiles "github.com/swaggo/files"
gs "github.com/swaggo/gin-swagger"
)

func (d *Devel) RegisterModule(rg *gin.RouterGroup, options *app.ServerOptions) {
if !options.FeatureOptions.Config.Server.Debug {
return
}

func (d *Devel) Register(rg *gin.RouterGroup, resolver *v1.Resolver) error {
rg.GET("/devel/*any", func(ctx *gin.Context) {
if ctx.Param("any") == "/" {
url := ctx.Request.URL
ctx.Redirect(http.StatusMovedPermanently, url.Path+"/index.html")
}
}, gs.WrapHandler(swaggerFiles.Handler))

return nil
}
5 changes: 5 additions & 0 deletions api/v1/devel/name.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package devel

func (h *Devel) GetApiName() string {
return "devel"
}
File renamed without changes.
46 changes: 46 additions & 0 deletions api/v1/history/filter.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package history

import (
"fmt"
"time"

v1 "github.com/anyshake/observer/api/v1"
"github.com/anyshake/observer/drivers/dao/tables"
"github.com/anyshake/observer/drivers/explorer"
)

func (h *History) filterHistory(startTime, endTime int64, maxDuration time.Duration, resolver *v1.Resolver) ([]explorer.ExplorerData, error) {
if endTime-startTime > maxDuration.Milliseconds() {
return nil, fmt.Errorf("duration is too large")
}

var (
adcCountModel tables.AdcCount
adcCountData []tables.AdcCount
)
err := resolver.Database.
Table(adcCountModel.GetName()).
Where("timestamp >= ? AND timestamp <= ?", startTime, endTime).
Order("timestamp ASC").
Find(&adcCountData).
Error
if err != nil {
return nil, err
}

var explorerData []explorer.ExplorerData
for _, record := range adcCountData {
explorerData = append(explorerData, explorer.ExplorerData{
Timestamp: record.Timestamp,
SampleRate: record.SampleRate,
Z_Axis: record.Z_Axis,
E_Axis: record.E_Axis,
N_Axis: record.N_Axis,
})
}

if len(explorerData) == 0 {
return nil, fmt.Errorf("no data available for the given time range")
}
return explorerData, nil
}
84 changes: 84 additions & 0 deletions api/v1/history/module.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package history

import (
"fmt"
"net/http"

v1 "github.com/anyshake/observer/api/v1"
"github.com/anyshake/observer/drivers/explorer"
"github.com/anyshake/observer/server/response"
"github.com/anyshake/observer/utils/logger"
"github.com/gin-gonic/gin"
)

// @Summary AnyShake Observer waveform history
// @Description Get waveform count data in specified time range, channel and format, the maximum duration of the waveform data to be exported is 24 hours for JSON and 1 hour for SAC
// @Router /history [post]
// @Accept application/x-www-form-urlencoded
// @Produce application/json
// @Produce application/octet-stream
// @Param start_time formData int true "Start timestamp of the waveform data to be queried, in milliseconds (unix timestamp)"
// @Param end_time formData int true "End timestamp of the waveform data to be queried, in milliseconds (unix timestamp)"
// @Param format formData string true "Format of the waveform data to be queried, `json` or `sac`"
// @Param channel formData string false "Channel of the waveform, `Z`, `E` or `N`, reuqired when format is `sac`"
// @Failure 400 {object} response.HttpResponse "Failed to export waveform data due to invalid format or channel"
// @Failure 410 {object} response.HttpResponse "Failed to export waveform data due to no data available"
// @Failure 500 {object} response.HttpResponse "Failed to export waveform data due to failed to read data source"
// @Success 200 {object} response.HttpResponse{data=[]explorer.ExplorerData} "Successfully exported the waveform data"
func (h *History) Register(rg *gin.RouterGroup, resolver *v1.Resolver) error {
rg.POST("/history", func(c *gin.Context) {
var binding historyBinding
if err := c.ShouldBind(&binding); err != nil {
logger.GetLogger(h.GetApiName()).Errorln(err)
response.Error(c, http.StatusBadRequest)
return
}

switch binding.Format {
case "json":
result, err := h.filterHistory(binding.StartTime, binding.EndTime, JSON_MAX_DURATION, resolver)
if err != nil {
logger.GetLogger(h.GetApiName()).Errorln(err)
response.Error(c, http.StatusGone)
return
}
response.Message(c, "The waveform data was successfully filtered", result)
return
case "sac":
result, err := h.filterHistory(binding.StartTime, binding.EndTime, SAC_MAX_DURATION, resolver)
if err != nil {
logger.GetLogger(h.GetApiName()).Errorln(err)
response.Error(c, http.StatusGone)
return
}
if binding.Channel != explorer.EXPLORER_CHANNEL_CODE_Z &&
binding.Channel != explorer.EXPLORER_CHANNEL_CODE_E &&
binding.Channel != explorer.EXPLORER_CHANNEL_CODE_N {
err := fmt.Errorf("no channel was selected")
logger.GetLogger(h.GetApiName()).Errorln(err)
response.Error(c, http.StatusBadRequest)
return
}
fileName, dataBytes, err := h.getSACBytes(
result,
resolver.Config.Stream.Station,
resolver.Config.Stream.Network,
resolver.Config.Stream.Location,
resolver.Config.Stream.Channel,
binding.Channel,
)
if err != nil {
logger.GetLogger(h.GetApiName()).Errorln(err)
response.Error(c, http.StatusInternalServerError)
return
}

response.File(c, fileName, dataBytes)
return
}

response.Error(c, http.StatusBadRequest)
})

return nil
}
5 changes: 5 additions & 0 deletions api/v1/history/name.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package history

func (h *History) GetApiName() string {
return "history"
}
Loading

0 comments on commit f0315ab

Please sign in to comment.