mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
make probe api service
This commit is contained in:
14
.vscode/launch.json
vendored
14
.vscode/launch.json
vendored
@@ -41,6 +41,20 @@
|
||||
"restart": true,
|
||||
"autoAttachChildProcesses": true
|
||||
},
|
||||
{
|
||||
"address": "127.0.0.1",
|
||||
"localRoot": "${workspaceFolder}/ProbeAPI",
|
||||
"name": "Probe API: Debug with Docker",
|
||||
"port": 9932,
|
||||
"remoteRoot": "/usr/src/app",
|
||||
"request": "attach",
|
||||
"skipFiles": [
|
||||
"<node_internals>/**"
|
||||
],
|
||||
"type": "node",
|
||||
"restart": true,
|
||||
"autoAttachChildProcesses": true
|
||||
},
|
||||
{
|
||||
"address": "127.0.0.1",
|
||||
"localRoot": "${workspaceFolder}/Workflow",
|
||||
|
||||
@@ -1,9 +1,56 @@
|
||||
node_modules/
|
||||
.vscode/
|
||||
.git
|
||||
|
||||
node_modules
|
||||
# See https://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
node_modules
|
||||
|
||||
.idea
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env
|
||||
|
||||
env.js
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
yarn.lock
|
||||
|
||||
yarn.lock
|
||||
Untitled-1
|
||||
*.local.sh
|
||||
*.local.yaml
|
||||
run
|
||||
stop
|
||||
|
||||
nohup.out*
|
||||
|
||||
encrypted-credentials.tar
|
||||
encrypted-credentials/
|
||||
|
||||
_README.md
|
||||
|
||||
# Important Add production values to gitignore.
|
||||
values-saas-production.yaml
|
||||
kubernetes/values-saas-production.yaml
|
||||
|
||||
/private
|
||||
|
||||
/tls_cert.pem
|
||||
/tls_key.pem
|
||||
/keys
|
||||
|
||||
temp_readme.md
|
||||
|
||||
tests/coverage
|
||||
|
||||
settings.json
|
||||
|
||||
GoSDK/tester/
|
||||
@@ -1,7 +0,0 @@
|
||||
MONGO_URL=mongodb://localhost:27017/oneuptimedb
|
||||
ONEUPTIME_SECRET=f414c23b4cdf4e84a6a66ecfd528eff2
|
||||
SLACK_ERROR_LOG_WEBHOOK=https://hooks.slack.com/services/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
|
||||
SLACK_ERROR_LOG_CHANNEL=oneuptime-engineering
|
||||
PORT=3400
|
||||
REALTIME_URL=http://localhost:3300
|
||||
DB_NAME=oneuptimedb
|
||||
1
ProbeAPI/.env.tpl
Normal file
1
ProbeAPI/.env.tpl
Normal file
@@ -0,0 +1 @@
|
||||
PORT={{ .Env.PROBE_API_PORT }}
|
||||
@@ -1,42 +0,0 @@
|
||||
import Express, {
|
||||
ExpressRequest,
|
||||
ExpressResponse,
|
||||
ExpressRouter,
|
||||
} from 'CommonServer/Utils/Express';
|
||||
|
||||
import ProbeAuthorization from 'CommonServer/Middleware/ProbeAuthorization';
|
||||
import Response from 'CommonServer/Utils/Response';
|
||||
import Exception from 'Common/Types/Exception/Exception';
|
||||
import PositiveNumber from 'Common/Types/PositiveNumber';
|
||||
|
||||
const router: ExpressRouter = Express.getRouter();
|
||||
|
||||
router.get(
|
||||
'/monitors',
|
||||
ProbeAuthorization.isAuthorizedProbeMiddleware,
|
||||
async (req: ExpressRequest, res: ExpressResponse) => {
|
||||
try {
|
||||
// const oneUptimeRequest: OneUptimeRequest = req as OneUptimeRequest;
|
||||
// const limit: PositiveNumber = new PositiveNumber(
|
||||
// parseInt((req.query['limit'] as string) || '10')
|
||||
// );
|
||||
|
||||
// const monitors: Array<Monitor> =
|
||||
// await MonitorService.getMonitorsNotPingedByProbeInLastMinute(
|
||||
// (oneUptimeRequest.probe as ProbeRequest).id,
|
||||
// limit
|
||||
// );
|
||||
|
||||
return Response.sendJsonArrayResponse(
|
||||
req,
|
||||
res,
|
||||
[],
|
||||
new PositiveNumber(0)
|
||||
);
|
||||
} catch (error) {
|
||||
return Response.sendErrorResponse(req, res, error as Exception);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
export default router;
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# OneUptime-ProbeAPI Dockerfile
|
||||
# OneUptime-probe-api Dockerfile
|
||||
#
|
||||
|
||||
# Pull base image nodejs image.
|
||||
@@ -11,6 +11,10 @@ RUN mkdir /tmp/npm && chmod 2777 /tmp/npm && chown 1000:1000 /tmp/npm && npm co
|
||||
# Install bash.
|
||||
RUN apk update && apk add bash && apk add curl
|
||||
|
||||
|
||||
# Install python
|
||||
RUN apk update && apk add --no-cache --virtual .gyp python3 make g++
|
||||
|
||||
#Use bash shell by default
|
||||
SHELL ["/bin/bash", "-c"]
|
||||
|
||||
@@ -55,6 +59,7 @@ COPY ./ProbeAPI/package*.json /usr/src/app/
|
||||
RUN npm install
|
||||
|
||||
# Expose ports.
|
||||
# - 3400: OneUptime-probe-api
|
||||
EXPOSE 3400
|
||||
|
||||
{{ if eq .Env.ENVIRONMENT "development" }}
|
||||
@@ -68,3 +73,4 @@ RUN npm run compile
|
||||
#Run the app
|
||||
CMD [ "npm", "start" ]
|
||||
{{ end }}
|
||||
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
test('two plus two is four', () => {
|
||||
expect(2 + 2).toBe(4);
|
||||
});
|
||||
@@ -76,6 +76,7 @@ DASHBOARD_API_PORT=3002
|
||||
API_DOCS_PORT=1445
|
||||
WORKFLOW_PORT=3099
|
||||
ALERT_PORT=3088
|
||||
PROBE_API_PORT=3400
|
||||
FILE_PORT=3125
|
||||
HOME_PORT=1444
|
||||
IDENTITY_PORT=3087
|
||||
|
||||
@@ -422,7 +422,49 @@ services:
|
||||
{{ end }}
|
||||
|
||||
|
||||
|
||||
probe-api:
|
||||
ports:
|
||||
- '3400:3400'
|
||||
{{ if eq .Env.ENVIRONMENT "development" }}
|
||||
- '9932:9229' # Debugging port.
|
||||
{{ end }}
|
||||
{{ if or (eq .Env.ENVIRONMENT "development") (eq .Env.ENVIRONMENT "ci") }}
|
||||
build:
|
||||
network: host
|
||||
context: .
|
||||
dockerfile: ./ProbeAPI/Dockerfile
|
||||
{{ else }}
|
||||
image: oneuptime/probe-api:{{ .Env.APP_TAG }}
|
||||
{{ end }}
|
||||
restart: always
|
||||
env_file:
|
||||
- ./Common/.env
|
||||
- ./CommonServer/.env
|
||||
- ./ProbeAPI/.env
|
||||
|
||||
depends_on:
|
||||
- redis
|
||||
- postgres
|
||||
- mail
|
||||
links:
|
||||
- redis
|
||||
- postgres
|
||||
- mail
|
||||
{{ if eq .Env.ENVIRONMENT "development" }}
|
||||
volumes:
|
||||
- ./ProbeAPI:/usr/src/app
|
||||
# Use node modules of the container and not host system.
|
||||
# https://stackoverflow.com/questions/29181032/add-a-volume-to-docker-but-exclude-a-sub-folder
|
||||
- /usr/src/app/node_modules/
|
||||
- ./Common:/usr/src/Common
|
||||
- ./Model:/usr/src/Model
|
||||
- ./CommonServer:/usr/src/CommonServer
|
||||
- ./CommonUI:/usr/src/CommonUI
|
||||
- /usr/src/Common/node_modules/
|
||||
- /usr/src/CommonUI/node_modules/
|
||||
- /usr/src/CommonServer/node_modules/
|
||||
- /usr/src/Model/node_modules/
|
||||
{{ end }}
|
||||
|
||||
file:
|
||||
ports:
|
||||
|
||||
Reference in New Issue
Block a user