nest.js 是 nodejs 服务运行时,要等待数据库服务启动完毕,也就是有一个启动等待的需求

https://juejin.im/entry/59a6325d6fb9a024932228e0 version: "2" services: app: build: ./ restart: always ports: - "5000:8000" links: - db - redis depends_on: - db - redis environment: WAIT_HOSTS: db:3306 redis:6379 CMD ./scripts/docker/wait-for.sh && npm run deploy #!/bin/bash set -e timeout=${WAIT_HOSTS_TIMEOUT:-30} waitAfterHosts=${WAIT_AFTER_HOSTS:-0} waitBeforeHosts=${WAIT_BEFORE_HOSTS:-0} echo "Waiting for ${waitBeforeHosts} seconds." sleep $waitBeforeHosts # our target format is a comma separated list where each item is "host:ip" if [ -n "$WAIT_HOSTS" ]; then uris=$(echo $WAIT_HOSTS | sed -e 's/,/ /g' -e 's/\s+/\n/g' | uniq) fi # wait for each target if [ -z "$uris" ]; then echo "No wait targets found." >&2; else for uri in $uris do host=$(echo $uri | cut -d: -f1) port=$(echo $uri | cut -d: -f2) [ -n "${host}" ] [ -n "${port}" ] echo "Waiting for ${uri}." seconds=0 while [ "$seconds" -lt "$timeout" ] && ! nc -z -w1 $host $port do echo -n . seconds=$((seconds+1)) sleep 1 done if [ "$seconds" -lt "$timeout" ]; then echo "${uri} is up!" else echo " ERROR: unable to connect to ${uri}" >&2 exit 1 fi done echo "All hosts are up" fi echo "Waiting for ${waitAfterHosts} seconds." sleep $waitAfterHosts exit 0

2019-05-08 · 1 min · 186 words · Me

nestjs vs code推荐插件

https://github.com/jiayisheji/blog/issues/18 vs code推荐插件:(其他插件自己随意) Debugger for Chrome – 调试 ejs – ejs文件高亮 Beautify – 代码格式化 DotENV – .env文件高亮 Jest – nest默认测试框架支持 TSLint – ts语法检查 TypeScript Hero – ts提示 vscode-icons – icons

2019-05-07 · 1 min · 30 words · Me

nest.js TypeORM Database

https://medium.com/@shaibenshimol/nestjs-and-mysql-in-10-minutes-711e02ec1dab ormconfig.json { "type": "mysql", "host": "localhost", "port": 3306, "username": "root", "password": "root", "database": "my_nestjs_project", "entities": ["src/**/**.entity{.ts,.js}"], "synchronize": true, "extra": { connectionLimit: 10, ... } } Very Important !! app.module import { Module } from '@nestjs/common'; import { UsersModule } from './users/users.module'; import { TypeOrmModule } from '@nestjs/typeorm'; @Module({ imports: [ TypeOrmModule.forRoot(), UsersModule ], }) export class AppModule {} =====nest command can use or not===== nest g module users nest g service users nest g controller users nest g class users/user.entity Use TypeORM Active Record https://github.com/typeorm/typeorm/blob/master/docs/active-record-data-mapper.md ...

2019-04-30 · 2 min · 390 words · Me

k8s kubernetes Lesson 7 ingress-nginx kubernetes

https://sueboy.blogspot.com/2019/01/ingress-nginx-kubernetes-ingress-with.html Real site is https://kubernetes.github.io/ingress-nginx/deploy/ kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/mandatory.yaml Verify installation https://kubernetes.github.io/ingress-nginx/deploy/#verify-installation kubectl get pods --all-namespaces -l app.kubernetes.io/name=ingress-nginx --watch Detect installed version https://kubernetes.github.io/ingress-nginx/deploy/#detect-installed-version shell script POD_NAMESPACE=ingress-nginx POD_NAME=$(kubectl get pods -n $POD_NAMESPACE -l app.kubernetes.io/name=ingress-nginx -o jsonpath='{.items[0].metadata.name}') kubectl exec -it $POD_NAME -n $POD_NAMESPACE -- /nginx-ingress-controller --version ========= Other nginx-ingress https://kubernetes.github.io/ingress-nginx/deploy/#using-helm

2019-04-26 · 1 min · 48 words · Me

[轉]How To Create a Kubernetes Cluster Using Kubeadm on Debian 9

https://www.digitalocean.com/community/tutorials/how-to-create-a-kubernetes-cluster-using-kubeadm-on-debian-9

2019-04-26 · 1 min · word · Me

geth add peers static-nodes.json

https://medium.com/taipei-ethereum-meetup/%E4%BB%A5%E5%A4%AA%E5%9D%8A%E7%A7%81%E7%B6%B2%E5%BB%BA%E7%AB%8B-%E4%B8%80-43f8677fc9f8 如果要組成一個私人網路,同樣按照上面的流程建立其他節點。如果沒有下–nodiscover參數的話,最後節點應該會找到彼此。如果有下的話就必須用手動的方式加入其他節點,加入的方式有三種: 一是在geth指令加入–bootnodes參數; 二是進到console裡使用 admin.addPeer(); 三是存成static-nodes.json檔,讓geth自動連線。 不管是使用哪一種,我們都要先知道要連到 static-nodes.json 裡面使用domain,可能會有問題,要自行更換ip Example: geth --data ~/data cp static-nodes.json ~/data/geth/static-nodes.json static-nodes.json like this [ "enode://53999cc519079c5190798b1114bd16a05a8d5190796cc51907988a4e80ebda7b6c519079e56b0b161da3475c4dc62f6b51907967a6e327e46aa56329c519079f@192.168.0.10:30303" ]

2019-04-24 · 1 min · 22 words · Me

[轉]The Ultimate Guide to Secure, Harden and Improve Performance of Nginx Web Server

https://www.tecmint.com/nginx-web-server-security-hardening-and-performance-tips/?fbclid=IwAR3WRK-N-buun8QIMDUbzes72-w6p8SKCxnzr0sGU_PFAyudPRbHiumtFu0

2019-04-23 · 1 min · word · Me

linux aws s3 exploer crossftp

https://www.tecmint.com/nginx-web-server-security-hardening-and-performance-tips/?fbclid=IwAR3WRK-N-buun8QIMDUbzes72-w6p8SKCxnzr0sGU_PFAyudPRbHiumtFu0

2019-04-23 · 1 min · word · Me

supertest jest

Jest Expect Methods https://jestjs.io/docs/en/expect it = test it('count > 30', async () => { await reqTarget.get("/members").expect(200) .then((res) => { //Can use foreach, more easy for(key in res.body){ //console.log(res.body\[key\].cou ); if (res.body\[key\].cou > 100) throw new Error("count: "+res.body\[key\].cou +" > 30"); //for vars value check message expect(res.body\[key\].cou ).toBeLessThan(30); } }); });

2019-04-23 · 1 min · 50 words · Me

geth 新版 豪秒產生無法匯入

geth新版的geth.log 會產生豪秒 舊 INFO [04-22|16:29:56] 新 INFO [03-28|13:43:35.004] 差別在.004 看log會發現只有logstash的warning,經同事正確解釋是: >>因為logstash轉換出來的日期格式2019-03-28 13:43:35.004,Elasticsearch不認得,所以對logstash來說是Warning,但對Elasticsearch是Error,造成Log寫不進去~ 所以在logstash.conf上必須在解析date上,補上 “YYYY-MM-dd HH:mm:ss,SSS”, “YYYY-MM-dd HH:mm:ss.SSS” date { match => \[ "gethdate" , "YYYY-MM-dd HH:mm:ss", "YYYY-MM-dd HH:mm:ss,SSS", "YYYY-MM-dd HH:mm:ss.SSS"\] target => "gethdate" timezone => "Asia/Taipei" } 這樣就可以正常匯入geth.log了

2019-04-23 · 1 min · 38 words · Me

Pinta windows linux mac

幸好Paint.NET是開放原始碼的軟體,於是有位任職於Novell公司,叫做Jonathan Pobst的開發者,利用了Paint.NET的原始碼,改用Gtk#函式庫開發了一款美工軟體,取名叫「Pinta」。 https://pinta-project.com/pintaproject/pinta/

2019-04-22 · 1 min · 3 words · Me

nodejs version npm problem install & run

You can do: 1. reget git clone 2. npm install 3. remove node_module 4. npm install agin 5. npm audit fix 6. npm start or run Sometime can Run.

2019-04-20 · 1 min · 29 words · Me

nodejs developer

g++ 安全 sudo apt-get install build-essential

2019-04-18 · 1 min · 6 words · Me

ganache-cli geth test developer ethereum

ethereum ganache-cli https://github.com/trufflesuite/ganache-cli

2019-04-18 · 1 min · 3 words · Me

linux git gui Guitar

https://github.com/soramimi/Guitar

2019-04-18 · 1 min · word · Me

ElastAlert elasticsearch elk

docker-compose version: '3.3' services: elasticsearch: build: context: elasticsearch/ volumes: #- ./elasticsearch/esdata:/usr/share/elasticsearch/data:rw - alldata:/usr/share/elasticsearch/data:rw #- ./elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro ports: - "9200:9200" - "9300:9300" environment: - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: memlock: soft: -1 hard: -1 nofile: soft: 65536 hard: 65536 networks: - fastdev logstash: build: context: logstash/ volumes: - ./logstash/config/logstash.yml:/etc/logstash/logstash.yml:ro - ./logstash/pipeline:/etc/logstash/conf.d:ro ports: - "5000:5000" - "5044:5044" environment: LS_JAVA_OPTS: "-Xmx256m -Xms256m" networks: - fastdev depends_on: - elasticsearch kibana: build: context: kibana/ volumes: - ./kibana/config/:/usr/share/kibana/config:ro ports: - "5601:5601" networks: - fastdev depends_on: - elasticsearch fakelog: build: context: fakelog/ volumes: - ./fakelog/logs:/ethereum-etl/output/:rw networks: - fastdev elastalert: build: context: elastalert/ volumes: - ./elastalert/config/config.json:/opt/elastalert-server/config/config.json:ro - ./elastalert/config/elastalert.yaml:/opt/elastalert/config.yaml:ro - ./elastalert/rules:/opt/elastalert/rules:rw - ./elastalert/rule_templates:/opt/elastalert/rule_templates:ro ports: - "3030:3030" # - "3333:3333" environment: - net=elasticsearch networks: - fastdev volumes: alldata: networks: fastdev: driver: bridge Only elasticsearch/Dockerfile some error happen because debian mirror. Other YAML see before blogs FROM java:8-jre # grab gosu for easy step-down from root ENV GOSU_VERSION 1.7 RUN set -x \ && wget -O /usr/local/bin/gosu "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture)" \ && wget -O /usr/local/bin/gosu.asc "https://github.com/tianon/gosu/releases/download/$GOSU_VERSION/gosu-$(dpkg --print-architecture).asc" \ && export GNUPGHOME="$(mktemp -d)" \ && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \ && gpg --batch --verify /usr/local/bin/gosu.asc /usr/local/bin/gosu \ && rm -r "$GNUPGHOME" /usr/local/bin/gosu.asc \ && chmod +x /usr/local/bin/gosu \ && gosu nobody true # https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-repositories.html # https://packages.elasticsearch.org/GPG-KEY-elasticsearch #RUN apt-key adv --keyserver ha.pool.sks-keyservers.net --recv-keys 46095ACC8548582C1A2699A9D27D666CD88E42B4 #ENV ELASTICSEARCH_MAJOR 1.7 #ENV ELASTICSEARCH_VERSION 1.7.5 #ENV ELASTICSEARCH_REPO_BASE http://packages.elasticsearch.org/elasticsearch/1.7/debian #RUN echo "deb $ELASTICSEARCH_REPO_BASE stable main" > /etc/apt/sources.list.d/elasticsearch.list #RUN set -x \ # && apt-get clean && apt-get update \ # && apt-get install -y --no-install-recommends elasticsearch=$ELASTICSEARCH_VERSION \ # && rm -rf /var/lib/apt/lists/* RUN wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | apt-key add - RUN echo "deb http://packages.elastic.co/elasticsearch/1.7/debian stable main" | tee -a /etc/apt/sources.list.d/elasticsearch-1.7.list RUN echo "deb [check-valid-until=no] http://archive.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/jessie.list RUN echo "deb [check-valid-until=no] http://cdn-fastly.deb.debian.org/debian jessie main" > /etc/apt/sources.list.d/jessie.list RUN echo "deb [check-valid-until=no] http://archive.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/jessie-backports.list RUN sed -i '/deb http:\/\/deb.debian.org\/debian jessie-updates main/d' /etc/apt/sources.list RUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install elasticsearch ENV PATH /usr/share/elasticsearch/bin:$PATH WORKDIR /usr/share/elasticsearch RUN set -ex \ && for path in \ ./data \ ./logs \ ./config \ ./config/scripts \ ; do \ mkdir -p "$path"; \ chown -R elasticsearch:elasticsearch "$path"; \ done COPY config ./config #VOLUME /usr/share/elasticsearch/data COPY docker-entrypoint.sh / RUN chmod +x /docker-entrypoint.sh EXPOSE 9200 9300 ENTRYPOINT ["/docker-entrypoint.sh"] CMD ["elasticsearch"] ElastAlert/Dockerfile FROM bitsensor/elastalert:latest ElastAlert/config/config.json { "appName": "elastalert-server", "port": 3030, "wsport": 3333, "elastalertPath": "/opt/elastalert", "verbose": false, "es_debug": false, "debug": false, "rulesPath": { "relative": true, "path": "/rules" }, "templatesPath": { "relative": true, "path": "/rule_templates" }, "es_host": "elasticsearch", "es_port": 9200, "writeback_index": "elastalert_status" } ElastAlert/config/elastalert.yaml es_host: elasticsearch es_port: 9200 rules_folder: rules # How often ElastAlert will query elasticsearch # The unit can be anything from weeks to seconds run_every: seconds: 5 #minutes: 1 # ElastAlert will buffer results from the most recent # period of time, in case some log sources are not in real time buffer_time: minutes: 15 # If an alert fails for some reason, ElastAlert will retry # sending the alert until this time period has elapsed alert_time_limit: minutes: 2 #days: 2 writeback_index: elastalert_status #smtp_host: "" ElastAlert/config/rules/test_metric.yaml name: Example rule # How often ElastAlert will query elasticsearch # The unit can be anything from weeks to seconds run_every: seconds: 5 #minutes: 1 # ElastAlert will buffer results from the most recent # period of time, in case some log sources are not in real time buffer_time: minutes: 15 # If an alert fails for some reason, ElastAlert will retry # sending the alert until this time period has elapsed alert_time_limit: minutes: 2 #days: 2 type: metric_aggregation index: filebeat-* metric_agg_key: project metric_agg_type: value_count #query_key: "name.keyword" doc_type: _type max_threshold: 32 min_threshold: 19 filter: - query: query_string: query: "srctype: geth AND project: hr AND mined AND geth_ip: \"xxx.xxx.xxx.xxx\"" #alert_subject: "No data on dashboard" # "|" means remove useless characters alert_text: | test attach alert_text_args: [] alert: - "email" email: - "1803110@narlabes.org.tw" ElastAlert/config/rule_templates copy file from github or not copy. https://github.com/Yelp/elastalert/tree/master/example_rules ...

2019-04-10 · 4 min · 680 words · Me

Docker-compose build Alpine image apk update fetch hangs

Alpine image apk update fetch hangs At apk –no-cache upgrade or RUN apk update no respone Try to login docker container run command line: wget http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz Get status is “stalled”. PS:Error is different “no respone” or “hang” Way one: Answer: apk fetch hangs https://github.com/gliderlabs/docker-alpine/issues/307 10G mtu or switch mtu So Into directory docker build --network host . Way two: Answer: https://mlohr.com/docker-mtu/ https://medium.com/@sylwit/how-we-spent-a-full-day-figuring-out-a-mtu-issue-with-docker-4d81fdfe2caf nano /etc/docker/daemon.json { "mtu": 1450 }

2019-04-02 · 1 min · 68 words · Me

[轉]HyperLedger Fabric 架构设计中的模式创新

https://www.chongdongshequ.com/article/1544005544333.html

2019-04-02 · 1 min · word · Me

flutter new hard

https://book.flutterchina.club/

2019-04-01 · 1 min · word · Me

flutter dart Streams Future

https://www.appcoda.com.tw/flutter-introduction/ Dart 內建支援 Streams 及 Future。我的 RxJava 經驗有助我了解 Streams,而在 ES6 Promise 方面的經驗則有助我理解 Futures 和 Async/Await 的概念

2019-04-01 · 1 min · 16 words · Me