forked from coop-cloud/wekan
Compare commits
53 Commits
0.1.0+v5.9
...
main
Author | SHA1 | Date | |
---|---|---|---|
4729fb7824
|
|||
eb951f1a1c | |||
70331d393f | |||
2286535613 | |||
2bd0920564 | |||
66e3194385 | |||
078fb53d4e | |||
1d9317c231 | |||
94cc1db80c | |||
17b1b99c9f | |||
b167073868 | |||
523aefdb4a | |||
4b71066eda | |||
f8d76d082b | |||
41de881966 | |||
51b24791a4 | |||
aa06f74560 | |||
b1609c5ef4 | |||
98d595d287 | |||
85c09e0fab | |||
53a08095f2 | |||
a9181c180e | |||
bc3b7a4dba | |||
d7a3f874c9 | |||
9b84875ea0 | |||
16753c808a | |||
16b48136e7 | |||
083310a964 | |||
d3e1340e03 | |||
28c8f7539a | |||
97a348ce29 | |||
3d94108785 | |||
a77f2c1ed9 | |||
a07ac5f0df | |||
f5b210f028 | |||
2d361c154a | |||
7782fd4d56 | |||
beac62e1c9 | |||
75bfa3f489 | |||
79a695c90a | |||
e46525e512 | |||
246a9229cb | |||
9224bb6238 | |||
9f89d5d475 | |||
d97a48af0e | |||
9b49dad813 | |||
3c88052a67 | |||
ccf2c7e223 | |||
a6ce73bb5b | |||
4275535838 | |||
688429c257 | |||
d71099a9dc | |||
5ce2801951 |
41
.drone.yml
Normal file
41
.drone.yml
Normal file
@ -0,0 +1,41 @@
|
||||
---
|
||||
kind: pipeline
|
||||
name: deploy to swarm-test.autonomic.zone
|
||||
steps:
|
||||
- name: deployment
|
||||
image: git.coopcloud.tech/coop-cloud/stack-ssh-deploy:latest
|
||||
settings:
|
||||
host: swarm-test.autonomic.zone
|
||||
stack: wekan
|
||||
generate_secrets: true
|
||||
purge: true
|
||||
deploy_key:
|
||||
from_secret: drone_ssh_swarm_test
|
||||
networks:
|
||||
- proxy
|
||||
environment:
|
||||
DOMAIN: wekan.swarm-test.autonomic.zone
|
||||
STACK_NAME: wekan
|
||||
LETS_ENCRYPT_ENV: production
|
||||
SECRET_OAUTH2_SECRET_VERSION: v1
|
||||
ENTRYPOINT_VERSION: v2
|
||||
SECRET_OAUTH2_SECRET_VERSION: v1
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
---
|
||||
kind: pipeline
|
||||
name: generate recipe catalogue
|
||||
steps:
|
||||
- name: release a new version
|
||||
image: plugins/downstream
|
||||
settings:
|
||||
server: https://build.coopcloud.tech
|
||||
token:
|
||||
from_secret: drone_abra-bot_token
|
||||
fork: true
|
||||
repositories:
|
||||
- toolshed/auto-recipes-catalogue-json
|
||||
|
||||
trigger:
|
||||
event: tag
|
113
.env.sample
113
.env.sample
@ -1,31 +1,106 @@
|
||||
TYPE=wekan
|
||||
TIMEOUT=300
|
||||
ENABLE_AUTO_UPDATE=true
|
||||
ENABLE_BACKUPS=true
|
||||
LETS_ENCRYPT_ENV=production
|
||||
SECRET_OAUTH2_SECRET_VERSION=v1
|
||||
|
||||
MONGO_URL=mongodb://db:27017/wekan
|
||||
COMPOSE_FILE="compose.yml"
|
||||
|
||||
DOMAIN=board.example.com
|
||||
ROOT_URL=https://board.example.com
|
||||
# Set this to run mongodb in replicaset mode (needs initialisation!)
|
||||
# COMPOSE_FILE="${COMPOSE_FILE}:compose.rs.yml"
|
||||
|
||||
DOMAIN=wekan.example.com
|
||||
ROOT_URL=https://wekan.example.com
|
||||
|
||||
DEBUG=false
|
||||
|
||||
OAUTH2_ENABLED=true
|
||||
OAUTH2_LOGIN_STYLE=redirect
|
||||
OAUTH2_CLIENT_ID=wekan
|
||||
OAUTH2_SERVER_URL=https://sso.example.com
|
||||
OAUTH2_AUTH_ENDPOINT=/application/o/authorize/
|
||||
OAUTH2_USERINFO_ENDPOINT=/application/o/userinfo/
|
||||
OAUTH2_TOKEN_ENDPOINT=/application/o/token/
|
||||
OAUTH2_REQUEST_PERMISSIONS="openid profile email wekan"
|
||||
OAUTH2_ID_MAP=preferred_username
|
||||
OAUTH2_USERNAME_MAP=preferred_username
|
||||
OAUTH2_FULLNAME_MAP=given_name
|
||||
OAUTH2_EMAIL_MAP=email
|
||||
|
||||
PASSWORD_LOGIN_ENABLED=false
|
||||
|
||||
MAIL_URL=smtp://smtp:25/?ignoreTLS=true&tls={rejectUnauthorized:false}
|
||||
MAIL_FROM="[WeKan] Wekan Notifications <noreply@example.org>"
|
||||
|
||||
WITH_API=true
|
||||
RICHER_CARD_COMMENT_EDITOR=false
|
||||
RICHER_CARD_COMMENT_EDITOR=false
|
||||
|
||||
# CORS=*
|
||||
# CORS_ALLOW_HEADERS=Authorization,Content-Type
|
||||
# CORS_EXPOSE_HEADERS=*
|
||||
|
||||
# PASSWORD_LOGIN_ENABLED=false
|
||||
|
||||
# LOGO_IMG_URL=https://authentik.example.com/static/dist/assets/icons/icon_left_brand.svg
|
||||
# LOGO_LINK_URL=https://authentik.example.com
|
||||
|
||||
### OAUTH2 ###
|
||||
|
||||
OAUTH2_ENABLED=false
|
||||
# OAUTH2_LOGIN_STYLE=redirect
|
||||
# OAUTH2_CLIENT_ID=wekan
|
||||
# OAUTH2_SERVER_URL=https://authentik.example.com
|
||||
# OAUTH2_AUTH_ENDPOINT=/application/o/authorize/
|
||||
# OAUTH2_USERINFO_ENDPOINT=/application/o/userinfo/
|
||||
# OAUTH2_TOKEN_ENDPOINT=/application/o/token/
|
||||
# OAUTH2_REQUEST_PERMISSIONS="openid profile email wekan"
|
||||
# OAUTH2_ID_MAP=preferred_username
|
||||
# OAUTH2_USERNAME_MAP=preferred_username
|
||||
# OAUTH2_FULLNAME_MAP=given_name
|
||||
# OAUTH2_EMAIL_MAP=email
|
||||
# PROPAGATE_OIDC_DATA=true
|
||||
# OIDC_REDIRECTION_ENABLED=true
|
||||
|
||||
|
||||
### LDAP ###
|
||||
|
||||
|
||||
|
||||
#COMPOSE_FILE="$COMPOSE_FILE:compose.ldap.yml"
|
||||
# DEFAULT_AUTHENTICATION_METHOD=ldap
|
||||
# LDAP_ENABLE=true
|
||||
# LDAP_PORT=389
|
||||
# LDAP_HOST=ldap.example.org
|
||||
# LDAP_AD_SIMPLE_AUTH=false
|
||||
# LDAP_USER_AUTHENTICATION=true
|
||||
# LDAP_USER_AUTHENTICATION_FIELD=cn
|
||||
# LDAP_DEFAULT_DOMAIN=mydomain.com
|
||||
# LDAP_BASEDN=dc=ldap,dc=goauthentik,dc=io
|
||||
# LDAP_LOGIN_FALLBACK=false
|
||||
# LDAP_RECONNECT=true
|
||||
# LDAP_TIMEOUT=10000
|
||||
# LDAP_IDLE_TIMEOUT=10000
|
||||
# LDAP_CONNECT_TIMEOUT=10000
|
||||
# LDAP_AUTHENTIFICATION=true
|
||||
# LDAP_AUTHENTIFICATION_USERDN=cn=admin,dc=ldap,dc=goauthentik,dc=io"
|
||||
# LDAP_AUTHENTIFICATION_PASSWORD=secret
|
||||
# LDAP_LOG_ENABLED=true
|
||||
# LDAP_BACKGROUND_SYNC=true
|
||||
# LDAP_BACKGROUND_SYNC_INTERVAL='every 1 hour'
|
||||
# LDAP_BACKGROUND_SYNC_KEEP_EXISTANT_USERS_UPDATED=true
|
||||
# LDAP_BACKGROUND_SYNC_IMPORT_NEW_USERS=true
|
||||
# LDAP_ENCRYPTION=false
|
||||
# LDAP_CA_CERT=-----BEGIN CERTIFICATE-----MIIE+G2FIdAgIC...-----END CERTIFICATE-----
|
||||
# LDAP_REJECT_UNAUTHORIZED=false
|
||||
# LDAP_USER_SEARCH_FILTER=
|
||||
# LDAP_USER_SEARCH_SCOPE=ou=users,dc=ldap,dc=goauthentik,dc=io
|
||||
# LDAP_USER_SEARCH_FIELD=cn
|
||||
# LDAP_SEARCH_PAGE_SIZE=0
|
||||
# LDAP_SEARCH_SIZE_LIMIT=0
|
||||
# Enable group filtering. Note the authenticated ldap user must be able to query all relevant group data with own login data from ldap.
|
||||
# LDAP_GROUP_FILTER_ENABLE=true
|
||||
# LDAP_GROUP_FILTER_OBJECTCLASS=group
|
||||
# LDAP_GROUP_FILTER_GROUP_ID_ATTRIBUTE=cn
|
||||
# LDAP_GROUP_FILTER_GROUP_MEMBER_ATTRIBUTE=member
|
||||
# LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT=dn
|
||||
# LDAP_GROUP_FILTER_GROUP_NAME=
|
||||
# LDAP_UNIQUE_IDENTIFIER_FIELD=guid
|
||||
# LDAP_UTF8_NAMES_SLUGIFY=true
|
||||
# LDAP_USERNAME_FIELD=cn
|
||||
# LDAP_FULLNAME_FIELD=name
|
||||
# LDAP_MERGE_EXISTING_USERS=true
|
||||
# LDAP_EMAIL_MATCH_ENABLE=true
|
||||
# LDAP_EMAIL_MATCH_REQUIRE=true
|
||||
# LDAP_EMAIL_MATCH_VERIFIED=true
|
||||
# LDAP_EMAIL_FIELD=mail
|
||||
# LDAP_SYNC_USER_DATA=true
|
||||
# LDAP_SYNC_USER_DATA_FIELDMAP={"cn":"name", "mail":"email"}
|
||||
# LDAP_SYNC_GROUP_ROLES=
|
||||
# LDAP_SYNC_ADMIN_STATUS=true
|
||||
# LDAP_SYNC_ADMIN_GROUPS=admin
|
||||
|
24
README.md
24
README.md
@ -27,3 +27,27 @@ See original [docker-compose.yml](https://github.com/wekan/wekan/blob/master/doc
|
||||
|
||||
|
||||
For more, see [`docs.coopcloud.tech`](https://docs.coopcloud.tech).
|
||||
|
||||
|
||||
## use mongodb with replicaset
|
||||
|
||||
needed to enable oplog setting in wekan, which isneeded to run bigger instances?
|
||||
|
||||
after mongo conaintainer came up the first time run:
|
||||
|
||||
```
|
||||
abra app run wekan.example.org db mongo
|
||||
> rs.initiate()
|
||||
```
|
||||
|
||||
## Promote user to admin
|
||||
|
||||
If using SSO, it might happen that there is no admin user. If so, you can fix it manually in the database:
|
||||
|
||||
```
|
||||
$ abra app run <app-name> db bash
|
||||
# mongo
|
||||
> use wekan
|
||||
> db.users.find({'username': '<your username>'})
|
||||
> db.users.updateOne({'_id': '<_id from result above>'}, {$set: {'isAdmin': true}})
|
||||
```
|
||||
|
27
abra.sh
27
abra.sh
@ -1,2 +1,25 @@
|
||||
export SECRET_OAUTH2_SECRET_VERSION=v1
|
||||
export ENTRYPOINT_VERSION=v1
|
||||
export ENTRYPOINT_VERSION=v4
|
||||
|
||||
set_settings(){
|
||||
mongosh wekan --eval '
|
||||
db.settings.updateOne(
|
||||
{},
|
||||
{
|
||||
$set: {
|
||||
"disableForgotPassword": true,
|
||||
"displayAuthenticationMethod" : false,
|
||||
"disableRegistration" : true,
|
||||
"customTopLeftCornerLogoImageUrl": "'$LOGO_IMG_URL'",
|
||||
"customTopLeftCornerLogoLinkUrl": "'$LOGO_LINK_URL'",
|
||||
}
|
||||
}
|
||||
)'
|
||||
}
|
||||
|
||||
show_mongo_version (){
|
||||
mongosh --eval 'db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )'
|
||||
}
|
||||
|
||||
update_mongo_version (){
|
||||
mongosh --eval 'db.adminCommand( { setFeatureCompatibilityVersion: "5.0" } )'
|
||||
}
|
||||
|
20
alaconnect.yml
Normal file
20
alaconnect.yml
Normal file
@ -0,0 +1,20 @@
|
||||
authentik:
|
||||
env:
|
||||
OAUTH2_ENABLED: "true"
|
||||
OAUTH2_SERVER_URL: https://authentik.example.com
|
||||
# TODO: set CLIENT_ID as secret
|
||||
OAUTH2_CLIENT_ID: wekan
|
||||
uncomment:
|
||||
- OAUTH2_LOGIN_STYLE
|
||||
- OAUTH2_AUTH_ENDPOINT
|
||||
- OAUTH2_USERINFO_ENDPOINT
|
||||
- OAUTH2_TOKEN_ENDPOINT
|
||||
- OAUTH2_REQUEST_PERMISSIONS
|
||||
- OAUTH2_ID_MAP
|
||||
- OAUTH2_USERNAME_MAP
|
||||
- OAUTH2_FULLNAME_MAP
|
||||
- OAUTH2_EMAIL_MAP
|
||||
- PROPAGATE_OIDC_DATA
|
||||
- OIDC_REDIRECTION_ENABLED
|
||||
shared_secrets:
|
||||
wekan_secret: oauth2_secret
|
54
compose.ldap.yml
Normal file
54
compose.ldap.yml
Normal file
@ -0,0 +1,54 @@
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
app:
|
||||
environment:
|
||||
- LDAP_ENABLE
|
||||
- LDAP_PORT
|
||||
- LDAP_HOST
|
||||
- LDAP_AD_SIMPLE_AUTH
|
||||
- LDAP_USER_AUTHENTICATION
|
||||
- LDAP_USER_AUTHENTICATION_FIELD
|
||||
- LDAP_DEFAULT_DOMAIN
|
||||
- LDAP_BASEDN
|
||||
- LDAP_LOGIN_FALLBACK
|
||||
- LDAP_RECONNECT
|
||||
- LDAP_TIMEOUT
|
||||
- LDAP_IDLE_TIMEOUT
|
||||
- LDAP_CONNECT_TIMEOUT
|
||||
- LDAP_AUTHENTIFICATION
|
||||
- LDAP_AUTHENTIFICATION_USERDN
|
||||
- LDAP_AUTHENTIFICATION_PASSWORD
|
||||
- LDAP_LOG_ENABLED
|
||||
- LDAP_BACKGROUND_SYNC
|
||||
- LDAP_BACKGROUND_SYNC_INTERVAL
|
||||
- LDAP_BACKGROUND_SYNC_KEEP_EXISTANT_USERS_UPDATED
|
||||
- LDAP_BACKGROUND_SYNC_IMPORT_NEW_USERS
|
||||
- LDAP_ENCRYPTION
|
||||
- LDAP_CA_CERT
|
||||
- LDAP_REJECT_UNAUTHORIZED
|
||||
- LDAP_USER_SEARCH_FILTER
|
||||
- LDAP_USER_SEARCH_SCOPE
|
||||
- LDAP_USER_SEARCH_FIELD
|
||||
- LDAP_SEARCH_PAGE_SIZE
|
||||
- LDAP_SEARCH_SIZE_LIMIT
|
||||
- LDAP_GROUP_FILTER_ENABLE
|
||||
- LDAP_GROUP_FILTER_OBJECTCLASS
|
||||
- LDAP_GROUP_FILTER_GROUP_ID_ATTRIBUTE
|
||||
- LDAP_GROUP_FILTER_GROUP_MEMBER_ATTRIBUTE
|
||||
- LDAP_GROUP_FILTER_GROUP_MEMBER_FORMAT
|
||||
- LDAP_GROUP_FILTER_GROUP_NAME
|
||||
- LDAP_UNIQUE_IDENTIFIER_FIELD
|
||||
- LDAP_UTF8_NAMES_SLUGIFY
|
||||
- LDAP_USERNAME_FIELD
|
||||
- LDAP_FULLNAME_FIELD
|
||||
- LDAP_MERGE_EXISTING_USERS
|
||||
- LDAP_EMAIL_MATCH_ENABLE
|
||||
- LDAP_EMAIL_MATCH_REQUIRE
|
||||
- LDAP_EMAIL_MATCH_VERIFIED
|
||||
- LDAP_EMAIL_FIELD
|
||||
- LDAP_SYNC_USER_DATA
|
||||
- LDAP_SYNC_USER_DATA_FIELDMAP
|
||||
- LDAP_SYNC_GROUP_ROLES
|
||||
- LDAP_SYNC_ADMIN_STATUS
|
||||
- LDAP_SYNC_ADMIN_GROUPS
|
10
compose.rs.yml
Normal file
10
compose.rs.yml
Normal file
@ -0,0 +1,10 @@
|
||||
version: "3.8"
|
||||
|
||||
services:
|
||||
db:
|
||||
command: mongod --oplogSize 128 --replSet rs0
|
||||
|
||||
app:
|
||||
environment:
|
||||
- MONGO_URL=mongodb://db:27017/wekan?replicaSet=rs01
|
||||
- MONGO_OPLOG_URL=mongodb://db:27017/local?replicaSet=rsWekan=value
|
65
compose.yml
65
compose.yml
@ -1,32 +1,44 @@
|
||||
version: '3.8'
|
||||
services:
|
||||
db:
|
||||
image: mongo:4.4
|
||||
command: mongod --logpath /dev/null --oplogSize 128 --quiet
|
||||
image: mongo:6.0
|
||||
environment:
|
||||
- LOGO_IMG_URL
|
||||
- LOGO_LINK_URL
|
||||
command: mongod --oplogSize 128 --quiet
|
||||
volumes:
|
||||
- wekan-db:/data/db
|
||||
networks:
|
||||
- internal
|
||||
healthcheck:
|
||||
test: echo 'db.runCommand("ping").ok' | mongo localhost:27017/test --quiet
|
||||
test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 10
|
||||
start_period: 1m
|
||||
deploy:
|
||||
labels:
|
||||
backupbot.backup: "true"
|
||||
backupbot.backup.pre-hook: "mkdir /tmp/backup/ && mongodump --archive=/tmp/backup/wekan.db"
|
||||
backupbot.backup.post-hook: "rm -rf /tmp/backup"
|
||||
backupbot.backup.path: "/tmp/backup/"
|
||||
backupbot.backup: "${ENABLE_BACKUPS:-true}"
|
||||
backupbot.backup.pre-hook: "mongodump --archive=/data/db/wekan.db"
|
||||
backupbot.backup.volumes.wekan-db.path: "wekan.db"
|
||||
backupbot.restore.post-hook: 'mongorestore --drop --archive=/data/db/wekan.db'
|
||||
|
||||
app:
|
||||
image: quay.io/wekan/wekan:v5.99
|
||||
image: quay.io/wekan/wekan:v7.91
|
||||
environment:
|
||||
- MONGO_URL
|
||||
- MONGO_URL=mongodb://db:27017/wekan
|
||||
- NODE_OPTIONS="--max_old_space_size=4096"
|
||||
- DOMAIN
|
||||
- ROOT_URL
|
||||
- DEBUG
|
||||
- MAIL_URL
|
||||
- MAIL_FROM
|
||||
- WITH_API
|
||||
- RICHER_CARD_COMMENT_EDITOR
|
||||
- CORS
|
||||
- CORS_ALLOW_HEADERS
|
||||
- CORS_EXPOSE_HEADERS
|
||||
- PASSWORD_LOGIN_ENABLED
|
||||
- OAUTH2_ENABLED
|
||||
- OAUTH2_LOGIN_STYLE
|
||||
- OAUTH2_CLIENT_ID
|
||||
@ -40,27 +52,28 @@ services:
|
||||
- OAUTH2_USERNAME_MAP
|
||||
- OAUTH2_FULLNAME_MAP
|
||||
- OAUTH2_EMAIL_MAP
|
||||
- PASSWORD_LOGIN_ENABLED
|
||||
- MAIL_URL
|
||||
- MAIL_FROM
|
||||
- WITH_API
|
||||
- RICHER_CARD_COMMENT_EDITOR
|
||||
- DEFAULT_AUTHENTICATION_METHOD
|
||||
- PROPAGATE_OIDC_DATA
|
||||
- OIDC_REDIRECTION_ENABLED
|
||||
- WRITABLE_PATH=/data
|
||||
volumes:
|
||||
- wekan-files:/data:rw
|
||||
networks:
|
||||
- internal
|
||||
- proxy
|
||||
- internal
|
||||
- proxy
|
||||
depends_on:
|
||||
- db
|
||||
healthcheck:
|
||||
test: node /build/healthcheck.js # no curl for healthcheck in wekan container
|
||||
test: bash /build/healthcheck.sh
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 10
|
||||
start_period: 1m
|
||||
start_period: 3m
|
||||
secrets:
|
||||
- oauth2_secret
|
||||
configs:
|
||||
- source: healthcheck_js
|
||||
target: /build/healthcheck.js
|
||||
- source: healthcheck_sh
|
||||
target: /build/healthcheck.sh
|
||||
mode: 0555
|
||||
- source: entrypoint
|
||||
target: /home/wekan/app/docker-entrypoint.sh
|
||||
@ -77,20 +90,22 @@ services:
|
||||
- "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`)"
|
||||
- "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure"
|
||||
- "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}"
|
||||
- "coop-cloud.${STACK_NAME}.version=0.1.0+v5.99"
|
||||
- "coop-cloud.${STACK_NAME}.version=3.3.0+v7.91"
|
||||
- "coop-cloud.${STACK_NAME}.timeout=${TIMEOUT:-120}"
|
||||
|
||||
volumes:
|
||||
wekan-db:
|
||||
|
||||
wekan-files:
|
||||
|
||||
networks:
|
||||
proxy:
|
||||
external: true
|
||||
internal:
|
||||
|
||||
configs:
|
||||
healthcheck_js:
|
||||
name: ${STACK_NAME}_healthcheck_js
|
||||
file: healthcheck.js
|
||||
healthcheck_sh:
|
||||
name: ${STACK_NAME}_healthcheck_sh
|
||||
file: healthcheck.sh
|
||||
entrypoint:
|
||||
name: ${STACK_NAME}_entrypoint_${ENTRYPOINT_VERSION}
|
||||
file: entrypoint.sh.tmpl
|
||||
|
@ -25,4 +25,8 @@ file_env() {
|
||||
}
|
||||
|
||||
file_env "OAUTH2_SECRET"
|
||||
node /build/main.js
|
||||
# https://github.com/wekan/wekan/issues/3585#issuecomment-1021522132
|
||||
#bash -c "ulimit -s 65500; exec node --stack-size=65500 /build/main.js"
|
||||
# https://github.com/wekan/wekan/pull/5588
|
||||
#bash -c "ulimit -n 65500; exec node /build/main.js"
|
||||
bash -c "exec node /build/main.js"
|
||||
|
@ -1,23 +0,0 @@
|
||||
const http = require('http');
|
||||
const options = {
|
||||
host: '0.0.0.0',
|
||||
port: 8080,
|
||||
timeout: 2000
|
||||
};
|
||||
|
||||
const healthCheck = http.request(options, (res) => {
|
||||
console.log(`HEALTHCHECK STATUS: ${res.statusCode}`);
|
||||
if (res.statusCode == 200) {
|
||||
process.exit(0);
|
||||
}
|
||||
else {
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
healthCheck.on('error', function (err) {
|
||||
console.error('ERROR');
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
healthCheck.end();
|
87
healthcheck.sh
Normal file
87
healthcheck.sh
Normal file
@ -0,0 +1,87 @@
|
||||
#!/bin/sh
|
||||
|
||||
printf "GET / HTTP/1.1\n\n" > /dev/tcp/127.0.0.1/8080
|
||||
if [ $? != 0 ]; then
|
||||
echo "Webservice not accessible"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CPU_USAGE_THRESHOLD=100.0
|
||||
|
||||
PID=$(pidof node)
|
||||
if [ -z "$PID" ]; then
|
||||
echo "Node.js process not running."
|
||||
exit 1
|
||||
fi
|
||||
STATE_FILE="/tmp/cpu_usage_state_$PID"
|
||||
|
||||
# Function to get total CPU time
|
||||
get_total_cpu_time() {
|
||||
cat /proc/stat | grep '^cpu ' | awk '{sum=0; for(i=2;i<=NF;i++) sum += $i; print sum;}'
|
||||
}
|
||||
|
||||
# Function to get process CPU time
|
||||
get_process_cpu_time() {
|
||||
cat /proc/$PID/stat | awk '{print $14+$15}' # Only user and system time
|
||||
}
|
||||
|
||||
# Function to get the number of CPUs
|
||||
get_cpu_count() {
|
||||
grep -c '^processor' /proc/cpuinfo
|
||||
}
|
||||
|
||||
# Main script
|
||||
if [ -z "$PID" ]; then
|
||||
echo "Usage: $0 <pid>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if the process directory exists
|
||||
if [ ! -d "/proc/$PID" ]; then
|
||||
echo "Process with PID $PID does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get current CPU times
|
||||
current_total=$(get_total_cpu_time)
|
||||
current_process=$(get_process_cpu_time $PID)
|
||||
|
||||
# Check for previous state
|
||||
if [ -f "$STATE_FILE" ]; then
|
||||
# Read previous state
|
||||
read prev_total prev_process < "$STATE_FILE"
|
||||
|
||||
# Calculate the CPU usage
|
||||
delta_total=$((current_total - prev_total))
|
||||
delta_process=$((current_process - prev_process))
|
||||
CPU_COUNT=$(get_cpu_count)
|
||||
|
||||
# Normalize CPU usage across all CPUs and calculate percentage
|
||||
if [ $delta_total -gt 0 ]; then # To avoid division by zero
|
||||
CPU_USAGE=$(awk -v delta_process="$delta_process" -v delta_total="$delta_total" -v cpu_count="$CPU_COUNT" \
|
||||
'BEGIN {printf "%.2f", (delta_process / delta_total) * 100 * cpu_count}')
|
||||
awk -v usage="$CPU_USAGE" -v threshold="$CPU_USAGE_THRESHOLD" '
|
||||
BEGIN {
|
||||
if (usage > threshold) {
|
||||
print "High CPU usage: " usage "% (Threshold: " threshold "%)";
|
||||
exit 1; # Exit with status 1 for high usage
|
||||
} else {
|
||||
print "CPU usage within limits: " usage "%";
|
||||
exit 0; # Normal exit status
|
||||
}
|
||||
}'
|
||||
EXIT_STATUS=$?
|
||||
else
|
||||
echo "No enough data to calculate CPU usage. Please try again."
|
||||
fi
|
||||
else
|
||||
echo "No previous data found. Run the script later to get CPU usage."
|
||||
fi
|
||||
|
||||
# Save current state
|
||||
echo "$current_total $current_process" > "$STATE_FILE"
|
||||
|
||||
if [ $EXIT_STATUS -ne 0 ]; then
|
||||
echo "Exiting due to high CPU usage."
|
||||
exit $EXIT_STATUS
|
||||
fi
|
7
release/3.0.0+v7.50
Normal file
7
release/3.0.0+v7.50
Normal file
@ -0,0 +1,7 @@
|
||||
Breaking Change: Update MongoDB from version 5.0 to 6.0.
|
||||
========================================================
|
||||
|
||||
Before updating:
|
||||
|
||||
Run `abra app cmd <app_domaon> db show_mongo_version` to check if the featureCompatibilityVersion is above 5.0 !
|
||||
Run `abra app cmd <app_domaon> db update_mongo_version` to set featureCompatibilityVersion to version 5.0
|
Reference in New Issue
Block a user