Skip to main content

Meta Crontab

meta system crontab job 

Dockerfile

FROM python:3.9-slim

ENV PYTHONUNBUFFERED=1
ENV TZ=Asia/Seoul
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN mkdir -p /apps
VOLUME ["/data/tomcat", "/data/tomcat"]
RUN mkdir -p /apps/filebeat-8.6.0-linux-x86_64
COPY ./filebeat-8.6.0-linux-x86_64 /apps/filebeat-8.6.0-linux-x86_64
RUN chmod go-w /apps/filebeat-8.6.0-linux-x86_64/filebeat.yml
RUN pip install --upgrade pip
RUN pip install psycopg2-binary
RUN pip install yt_dlp
COPY ./python-programes /apps
ENTRYPOINT ["/apps/filebeat-8.6.0-linux-x86_64/startfilebeat.sh"]

실행 Shell

#!/bin/bash

VERSION=$1

echo ">> Build Version : " $VERSION

docker build -t tomcat-meta-batch:$VERSION /data/tomcat/scm/dockerimage/meta-batch

docker tag tomcat-meta-batch:$VERSION web.joang.com:9002/tomcat-meta-batch:$VERSION
docker tag tomcat-meta-batch:$VERSION web.joang.com:9002/tomcat-meta-batch:latest

docker push web.joang.com:9002/tomcat-meta-batch:$VERSION
docker push web.joang.com:9002/tomcat-meta-batch:latest

exit 0

실행 : ./dockerbuild.sh 1

docker run -it --name=python-test tomcat-meta-batch:1 /bin/bash

들어가서 확인 ! 

실행하면 이미 실행하고 이다고 나오면 삭제  :  

docker rm 3e8aafcd3e8a77434d6e263b9459ae8e290c4b5f4b0ba58d0007ca7eff778d2e --force

그리고 다시 시작 !

-----------------------

Meta Backup Batch 

apiVersion: batch/v1beta1 
kind: CronJob 
metadata:
  name: tomcat-meta-batch 
  namespace: tomcat-apps
spec:
  schedule: "*/15 * * * *"
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: tomcat-meta-batch 
            image: 192.168.0.10:9002/tomcat-meta-batch:latest 
            command:
            - /bin/sh
            - -c
            - /apps/startBackUpBatch.sh > /apps/batch.log
            volumeMounts:
            - name: tomcat-volume
              mountPath: /data/tomcat
          volumes:
          - name: tomcat-volume
            hostPath:
              path: /data/tomcat
              type: Directory
          restartPolicy: OnFailure
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1

Download Youtube 

apiVersion: batch/v1beta1 
kind: CronJob 
metadata:
  name: tomcat-meta-youtube 
  namespace: tomcat-apps
spec:
  schedule: "*/10 * * * *"
  concurrencyPolicy: Forbid
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: tomcat-meta-youtube 
            image: 192.168.0.10:9002/tomcat-meta-batch:latest 
            command:
            - /bin/sh
            - -c
            - /apps/startYouTuBe.sh > /apps/youtube.log
            volumeMounts:
            - name: tomcat-volume
              mountPath: /data/tomcat
          volumes:
          - name: tomcat-volume
            hostPath:
              path: /data/tomcat
              type: Directory
          restartPolicy: OnFailure
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1