Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging service #52

Open
wants to merge 90 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 82 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
a75f4e4
Non-working ICMP ping
MasterSushiChef Nov 2, 2018
4fc6eab
Installed net-ping
MasterSushiChef Oct 28, 2018
ddee361
Added DevicePing protobuf message and 'icmp' field in PingTimes
MasterSushiChef Oct 28, 2018
26edfb7
Changed device ping function
MasterSushiChef Nov 2, 2018
d3d2f12
Not working tests
MasterSushiChef Nov 9, 2018
340b1a3
Implemented ICMP pinging of devices
MasterSushiChef Nov 18, 2018
786275f
Removed semicolon in Dockerfile.test and readded list field in PingTi…
MasterSushiChef Nov 19, 2018
039da78
Copy raw-socket instead of gphoto2
MasterSushiChef Nov 19, 2018
6a44da7
Start of logging service
MasterSushiChef Dec 7, 2018
15d2cf8
Rough outline of logging service
MasterSushiChef Dec 7, 2018
9c1f83b
added capability to log data from api pings
MasterSushiChef Jan 27, 2019
ad8367a
updated fields for service constructor and influx database
MasterSushiChef Jan 27, 2019
91de9ea
Updated tests
MasterSushiChef Feb 1, 2019
8db8233
Connected InfluxDB and Grafana
MasterSushiChef Feb 18, 2019
cdeee53
Logging service files
MasterSushiChef Feb 18, 2019
ef3947b
Deleted old L O G S service
MasterSushiChef Feb 18, 2019
bd73c55
Ping data displaying in grafana
MasterSushiChef Feb 24, 2019
00b6c52
Merge branch 'master' of https://github.com/uavaustin/orchestra into …
MasterSushiChef Feb 24, 2019
870fa71
fix merge conflicts with pong
MasterSushiChef Feb 24, 2019
8b99b45
Added functionality to get telemetry uptime
MasterSushiChef Mar 11, 2019
f64c027
Added telemetry status to database
MasterSushiChef Mar 29, 2019
1047f75
Added 'ONLINE' and 'OFFLINE' statuses for telemetry service
MasterSushiChef Apr 5, 2019
0bdc5be
gitignore
MasterSushiChef Apr 5, 2019
feee525
Updated alpine version so libsll1.1 can install
MasterSushiChef Apr 7, 2019
4bd9fde
Added env variables to Dockerfile
MasterSushiChef Apr 7, 2019
94a7de1
Added lumberjack to orchestra make
MasterSushiChef Apr 7, 2019
647e155
Added function and endpoint to get connection state of the plane
MasterSushiChef Apr 7, 2019
03164fe
Changed name of variables in lumberjack Makefile
MasterSushiChef Apr 12, 2019
69541ce
Added additional env variables to start-service
MasterSushiChef Apr 12, 2019
f99b201
-Implemented ability to get status of plane telemetry through length …
MasterSushiChef Apr 12, 2019
d3b5c06
Add function to get lenght of task queue
MasterSushiChef Apr 14, 2019
b324aed
lumberjack now depends on forward-interop and pong
MasterSushiChef Apr 14, 2019
5f68d54
Added port variable
MasterSushiChef Apr 14, 2019
a9822d6
Includes grafana json file
MasterSushiChef Apr 19, 2019
6d1460d
grafana config (?)
MasterSushiChef Apr 21, 2019
1fbcae1
delete useless grafana files
MasterSushiChef Apr 26, 2019
2f718c7
Add Grafana provisioning files
oldmud0 Apr 28, 2019
c67abc0
Tests for lumberjack
MasterSushiChef Apr 29, 2019
33daa65
Merge branch 'logging-service' of https://github.com/uavaustin/orches…
MasterSushiChef Apr 29, 2019
4ffe00e
Minor style fixes in lumberjack
oldmud0 Apr 29, 2019
26f77b9
Update package.json
MasterSushiChef Apr 30, 2019
b403780
Delete package-lock.json
MasterSushiChef Apr 30, 2019
c26f936
Update docker compose
MasterSushiChef Apr 30, 2019
be25727
Delete router.js
MasterSushiChef Apr 30, 2019
6f48b4b
Remove package-lock.json
MasterSushiChef Apr 30, 2019
e758295
Merge branch 'logging-service' of https://github.com/uavaustin/orches…
MasterSushiChef Apr 30, 2019
49a2d75
Small features added and fixes
MasterSushiChef Apr 30, 2019
05e038a
Add lumberjack to Travis CI
oldmud0 Apr 30, 2019
625475e
eslint file
MasterSushiChef May 3, 2019
3b43921
Merge branch 'logging-service' of https://github.com/uavaustin/orches…
MasterSushiChef May 3, 2019
97687b6
Remove task queue
MasterSushiChef May 3, 2019
4da1cd0
Removed task queue function from telemetry
MasterSushiChef May 3, 2019
b91279f
Remove Grafana provisioning files
oldmud0 May 3, 2019
a3abb83
Remove .DS_Store
oldmud0 May 3, 2019
6d57057
Plane telemetry task
MasterSushiChef May 3, 2019
6e62325
Updated to include task intervals across tests and services
MasterSushiChef May 3, 2019
c526960
Merge branch 'logging-service' of https://github.com/uavaustin/orches…
MasterSushiChef May 3, 2019
3f4f318
Fixed timing problems with tests
MasterSushiChef May 10, 2019
6f0eac9
Add babelrc file
MasterSushiChef May 10, 2019
8ffb903
Added plane telemetry task
MasterSushiChef May 12, 2019
5f0d1c0
Tests for plane telemetry
MasterSushiChef May 12, 2019
8ff243b
fix for plane telemetry
MasterSushiChef May 12, 2019
314bbbc
Merge branch 'master' of https://github.com/uavaustin/orchestra into …
MasterSushiChef May 13, 2019
f9b98a8
Merge fixes
MasterSushiChef May 13, 2019
748ef2e
Lumberjack: DRY the code a bit
oldmud0 Jun 5, 2019
eafd29c
Lumberjack: Address PR review
oldmud0 Jun 9, 2019
ab06a87
Fixed '' host issue, container start up timing
MasterSushiChef Jun 13, 2019
3df8f60
Assign statuses to 1 or 0
MasterSushiChef Jul 10, 2019
854c5cf
comment
MasterSushiChef Sep 29, 2019
283a819
update interop-server image
MasterSushiChef Sep 29, 2019
1e3fd5d
line length
MasterSushiChef Sep 29, 2019
badc160
literally a space
MasterSushiChef Oct 2, 2019
d15f838
stop and remove influxdb container after testing
MasterSushiChef Oct 20, 2019
d096959
didn't catch a space
MasterSushiChef Oct 20, 2019
53478a8
Merge pull request #67 from uavaustin/logging-test-fix
MasterSushiChef Oct 20, 2019
f37be96
Adds the code that clear all InfluxDB database.
vinaxue Oct 23, 2019
1a83d55
Changes the mode of the files back to 644
vinaxue Oct 23, 2019
39a8060
Added a router file for lumberjack.
vinaxue Oct 23, 2019
69259a2
Merge branch 'logging-service' of https://github.com/uavaustin/orches…
vinaxue Oct 23, 2019
7ae69f7
Condensed the clearData code.
vinaxue Oct 23, 2019
a72331c
begin work on more unit tests
MasterSushiChef Feb 7, 2020
1f458a2
update tests
MasterSushiChef Feb 9, 2020
b8d8907
Merge branch 'master' into logging-service
MasterSushiChef Feb 9, 2020
c83ceab
fix grafana in testing
MasterSushiChef Feb 23, 2020
f02376a
Revert "fix grafana in testing"
5Nosaj5 Oct 28, 2020
d77f00c
Added Lumberjack timestamps
5Nosaj5 Nov 8, 2020
6327bac
Format fixed
5Nosaj5 Nov 8, 2020
483961b
fix grafana again
senkevinli Nov 20, 2020
84c85ce
updated timing lumberjack
senkevinli Nov 20, 2020
cd23918
env variable support
senkevinli Nov 20, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- env: SERVICE=forward-interop
- env: SERVICE=imagery
- env: SERVICE=dashboard
- env: SERVICE=lumberjack
- env: SERVICE=image-rec-master
- stage: test
env: SERVICE_TEST=telemetry
Expand All @@ -35,9 +36,13 @@ jobs:
- env: SERVICE_TEST=imagery
language: node_js
node_js: '8'
- env: SERVICE_TEST=lumberjack
language: node_js
node_js: '8'
- env: SERVICE_TEST=image-rec-master
language: python
python: '3.7'

notifications:
email: false
webhooks:
Expand Down
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# See service level Makefiles for more fine-grained control.

.PHONY: all

all: mavproxy telemetry interop-proxy pong forward-interop imagery dashboard \
image-rec-master
lumberjack image-rec-master

.PHONY: test
test: telemetry-test interop-proxy-test pong-test forward-interop-test \
imagery-test image-rec-master-test
imagery-test image-rec-master-test lumberjack-test

.PHONY: mavproxy
mavproxy:
Expand Down Expand Up @@ -56,6 +57,14 @@ imagery-test:
dashboard:
$(MAKE) -C services/dashboard

.PHONY: lumberjack
lumberjack:
$(MAKE) -C services/lumberjack

.PHONY: lumberjack-test
lumberjack-test:
$(MAKE) -C services/lumberjack test

.PHONY: image-rec-master
image-rec-master:
$(MAKE) -C services/image-rec-master
Expand All @@ -73,4 +82,5 @@ clean:
$(MAKE) -C services/forward-interop clean
$(MAKE) -C services/imagery clean
$(MAKE) -C services/dashboard clean
$(MAKE) -C services/lumberjack clean
$(MAKE) -C services/image-rec-master clean
1 change: 0 additions & 1 deletion services/common/messages/stats.proto
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ message PingTimes {
}

double time = 1;
// Use service_pings instead, will remove.
repeated ServicePing list = 2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what ended up happening with this?

repeated ServicePing service_pings = 3;
repeated DevicePing device_pings = 4;
Expand Down
23 changes: 23 additions & 0 deletions services/lumberjack/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"sourceMaps": "inline",
"plugins": [
"add-module-exports"
],
"presets": [
[
"env",
{
"targets": {
"node": "current"
}
}
]
],
"env": {
"development": {
"plugins": [
"source-map-support"
]
}
}
}
32 changes: 32 additions & 0 deletions services/lumberjack/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
env:
es6: true
node: true
plugins:
- jest
extends:
- 'eslint:recommended'
- 'plugin:jest/recommended'
parserOptions:
ecmaVersion: 2017
sourceType: module
rules:
max-len:
- error
- code: 79
- comments: 69
no-trailing-spaces:
- error
eol-last:
- error
no-multiple-empty-lines:
- error
- max: 1
indent:
- error
- 2
quotes:
- error
- single
semi:
- error
- always
16 changes: 16 additions & 0 deletions services/lumberjack/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Ignore things from npm.
node_modules/
npm-debug.log*
package-lock.json

# Ignore common directories.
src/common
src/messages

# Ignore babel and message output.
lib/
src/messages.js

# Ignore coverage output.
.nyc_output
coverage
73 changes: 73 additions & 0 deletions services/lumberjack/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
ARG BASE=node:8-alpine

# Compile our js source.
FROM ${BASE} AS builder

WORKDIR /builder

RUN apk --no-cache add \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a dependency that needs to build from source in this package?

make \
g++ \
python-dev

COPY common/nodejs/package.json src/common/
COPY lumberjack/package.json .

RUN npm install

COPY common/messages/stats.proto \
common/messages/telemetry.proto \
src/messages/

RUN npm run build-msg

COPY common/nodejs src/common
COPY lumberjack .

RUN npm run build

# Make the actual image now.
FROM ${BASE}

WORKDIR /app

ENV NODE_ENV=production

COPY common/scripts/wait-for-it.sh .

RUN apk --no-cache add \
curl

COPY common/nodejs/package.json src/common/
COPY lumberjack/package.json .

RUN npm install

# Add in the output from the js builder above.
COPY --from=builder /builder/lib lib

COPY /lumberjack/bin bin

ENV INFLUX_HOST='influx' \
INFLUX_PORT=8086 \
PING_HOST='pong' \
PING_PORT=7000 \
FORWARD_INTEROP_HOST='forward-interop' \
FORWARD_INTEROP_PORT=4000 \
GROUND_TELEMETRY_HOST='telemetry' \
GROUND_TELEMETRY_PORT=5000 \
PLANE_TELEMETRY_HOST='' \
PLANE_TELEMETRY_PORT=5000 \
UPLOAD_INTERVAL=1000 \
PING_INTERVAL=1000 \
TELEM_INTERVAL=1000 \
DB_NAME='lumberjack'

EXPOSE 6000

# Wait for response from influx database first.
CMD ./wait-for-it.sh \
"http://$INFLUX_HOST:$INFLUX_PORT/ping" \
"influxdb" && \
printf 'Starting.\n' && \
FORCE_COLOR=1 npm start --silent
28 changes: 28 additions & 0 deletions services/lumberjack/Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ARG BASE=node:8-alpine

FROM ${BASE}

ENV NODE_ENV=test

WORKDIR /test

RUN apk --no-cache add \
MasterSushiChef marked this conversation as resolved.
Show resolved Hide resolved
make \
g++ \
python-dev

COPY common/nodejs/package.json src/common/
COPY lumberjack/package.json .

RUN npm install

COPY common/messages/stats.proto \
common/messages/telemetry.proto \
src/messages/

RUN npm run build-msg

COPY common/nodejs src/common
COPY lumberjack .

CMD npm run lint && npm test
37 changes: 37 additions & 0 deletions services/lumberjack/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Flags for docker when building images, meant to be overridden
DOCKERFLAGS :=

LUMBERJACK_IMAGE := uavaustin/lumberjack
LUMBERJACK_TEST_IMAGE := uavaustin/lumberjack-test
ALPINE_IMAGE := alpine
INFLUX_IMAGE := influxdb:alpine

current_dir := $(shell pwd)

.PHONY: all
all: image

.PHONY: image
image:
docker build -t $(LUMBERJACK_IMAGE) -f Dockerfile $(DOCKERFLAGS) ..

.PHONY: test
test: alpine
docker build -t $(LUMBERJACK_TEST_IMAGE) -f Dockerfile.test $(DOCKERFLAGS) ..
docker run -it --rm -v $(current_dir)/coverage:/test/coverage \
-v /var/run/docker.sock:/var/run/docker.sock $(LUMBERJACK_TEST_IMAGE)

.PHONY: alpine
alpine:
@if ! docker inspect --type=image $(ALPINE_IMAGE) &> /dev/null; then \
docker pull $(ALPINE_IMAGE); \
fi
@if ! docker inspect --type=image $(INFLUX_IMAGE) &> /dev/null; then \
docker pull $(INFLUX_IMAGE); \
fi

.PHONY: clean
clean:
rm -rf node_modules lib package-lock.json
docker rmi -f $(LUMBERJACK_IMAGE)
docker rmi -f $(LUMBERJACK_TEST_IMAGE)
24 changes: 24 additions & 0 deletions services/lumberjack/bin/start-service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env node

const Service = require('..');

let service = new Service({
influxHost: process.env.INFLUX_HOST,
influxPort: process.env.INFLUX_PORT,
pingHost: process.env.PING_HOST,
pingPort: process.env.PING_PORT,
forwardInteropHost: process.env.FORWARD_INTEROP_HOST,
forwardInteropPort: process.env.FORWARD_INTEROP_PORT,
groundTelemetryHost: process.env.GROUND_TELEMETRY_HOST,
groundTelemetryPort: process.env.GROUND_TELEMETRY_PORT,
planeTelemetryHost: process.env.PLANE_TELEMETRY_HOST,
planeTelemetryPort: process.env.PLANE_TELEMETRY_PORT,
uploadInterval: process.env.UPLOAD_INTERVAL,
pingInterval: process.env.PING_INTERVAL,
telemInterval: process.env.TELEM_INTERVAL,
dbName: process.env.DB_NAME
});

service.start();

process.once('SIGINT', () => service.stop());
9 changes: 9 additions & 0 deletions services/lumberjack/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
testEnvironment: 'node',
collectCoverage: true,
collectCoverageFrom: [
'src/**/*.js',
'!src/common/**',
'!src/messages.js'
]
}
38 changes: 38 additions & 0 deletions services/lumberjack/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "lumberjack",
"version": "0.1.0",
"main": "lib/service.js",
"private": true,
"license": "MIT",
"scripts": {
"start": "node ./bin/start-service",
"build": "babel src --out-dir lib",
"build-msg": "mkdir -p lib && pbjs -t static-module --es6 --keep-case -o src/messages.js src/messages/*.proto",
"test": "jest",
"lint": "eslint src test --ignore-pattern src/messages.js"
},
"dependencies": {
"common-nodejs": "file:src/common",
"koa": "^2.5.1",
"influx": "^5.0.7",
"koa-router": "^7.4.0",
oldmud0 marked this conversation as resolved.
Show resolved Hide resolved
"koa-protobuf": "^0.1.0",
"protobufjs": "~6.8.6",
"source-map-support": "^0.5.6",
"superagent": "^3.8.3",
"superagent-protobuf": "^0.1.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-source-map-support": "^2.0.1",
"babel-preset-env": "^1.6.1",
"dockerode": "^2.5.7",
"eslint": "^5.3.0",
"eslint-plugin-jest": "^21.20.2",
"jest": "^23.3.0",
"lolex": "^4.0.1",
"nock": "^9.6.1",
"supertest": "^3.1.0"
}
}
17 changes: 17 additions & 0 deletions services/lumberjack/src/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import koaProtobuf from 'koa-protobuf';
import Router from 'koa-router';

let router = new Router();

// Encode outbound protobuf messages.
router.use(koaProtobuf.protobufSender());

router.get('/api/alive', (ctx) => {
ctx.body = 'Yo dude, I\'m good.\n';
});

router.get('/api/clear-data', (ctx) => {
ctx.body = ctx.service.clearData();
});

export default router;
Loading