Skip to content
This repository has been archived by the owner on Jul 1, 2019. It is now read-only.

Commit

Permalink
나름 업데이트
Browse files Browse the repository at this point in the history
1. makerss 스크립트 업데이트
2. yaml 대신에 원본 방식 그대로 쓰도록
3. crontab과 tz 제거, 호스트의 cron이나 스케쥴러를 사용하세요.
4. 로그도 제거
  • Loading branch information
wiserain committed Nov 20, 2018
1 parent 40eda94 commit 94022e0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 322 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Expand Up @@ -10,12 +10,10 @@ ENV TZ Asia/Seoul
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
cron \
bzip2 \
libfontconfig \
python-pip \
python-urllib3 \
python-yaml \
&& pip install --ignore-installed \
selenium \
&& apt-get clean \
Expand All @@ -37,6 +35,8 @@ RUN set -x \

# add and set permission of scripts
COPY /root /
ADD https://raw.githubusercontent.com/soju6jan/soju6jan.github.io/master/makerss/makerss_main.py /makerss
ADD https://raw.githubusercontent.com/soju6jan/soju6jan.github.io/master/makerss/makerss_setting.py /makerss
RUN chmod +x /usr/bin/makerss*

VOLUME /config /rssxml
Expand Down
11 changes: 1 addition & 10 deletions README.md
Expand Up @@ -13,24 +13,15 @@ docker run -d \
-v <path to generated rssxml>:/rssxml \
-e PUID=<UID for user> \
-e PGID=<GID for user> \
-e TZ=<timezone> \
wiserain/makerss
```

초기화 과정을 진행하고 phantomjs를 띄워서 준비 상태가 됩니다.

```/config```와 매핑된 폴더에 ```config.yml``` 파일이 준비되어 있습니다. 사이트를 주석 처리하거나 게시판을 추가하여 자신만의 설정을 저장하고 아래 명령어를 실행합니다. (yaml 형식으로 되어 있으니 편집할때 참고 바랍니다.)
```/config```와 매핑된 폴더에 ```makerss_*.py``` 파일이 준비되어 있습니다. 사이트를 주석 처리하거나 게시판을 추가하여 자신만의 설정을 저장하고 아래 명령어를 실행합니다. (자세한 내용은 상단의 설명 참고)

```bash
docker exec -it <container name> makerss_run
```

백그라운드 실행은 ```-it``` 대신 ```-d```를 입력합니다.

### Cronjob

환경변수를 통해 컨테이너 내부의 crontab을 설정할 수 있습니다. 가장 앞의 5개 인자(분시일월주)만 입력하면 됩니다. 예외 처리가 되어 있지 않으니 참고해 주세요.

```bash
-e CRONTAB="* * * * *"
```
67 changes: 0 additions & 67 deletions root/makerss/config.default.yml

This file was deleted.

220 changes: 0 additions & 220 deletions root/makerss/makerss.py

This file was deleted.

35 changes: 14 additions & 21 deletions root/usr/bin/makerss_init
Expand Up @@ -2,14 +2,6 @@
set +x # -x: print all / +x: print echo only
set -e # terminate immediately in case of error

# Timezone setting
if [ -n "${TZ}" ]; then
echo "[Init] Local timezone to ${TZ}"
echo "${TZ}" > /etc/timezone
rm /etc/localtime
dpkg-reconfigure -f noninteractive tzdata
fi

if [ ! -d /config ]; then
mkdir -p /config
fi
Expand Down Expand Up @@ -43,23 +35,24 @@ fi
chown -R "${makerss_user}":"${makerss_group}" /config /rssxml
chmod -R 775 /config /rssxml

# Check if config.yml exists. If not, copy in
if [ -f /config/config.yml ]; then
echo "[Init] Using existing config.yml"
# copy makerss scripts
if [ -f /config/makerss_main.py ]; then
echo "[Init] Using existing makerss_main.py"
else
echo "[Init] New config.yml from default"
cp /makerss/config.default.yml /config/config.yml
echo "[Init] New makerss_main.py from default"
cp /makerss/makerss_main.py /config/makerss_main.py
if [ -n "$makerss_user" ]; then
chown "${makerss_user}":"${makerss_group}" /config/config.yml
chown "${makerss_user}":"${makerss_group}" /config/makerss_main.py
fi
fi

if [ ! -z "${CRONTAB}" ]; then
echo "[Init] Setting cronjob"
echo "${CRONTAB} root /bin/sh /usr/bin/makerss_run" > /etc/cron.d/makerss
crontab /etc/cron.d/makerss
touch /config/makerss.log
cron && tail -f /config/makerss.log &
if [ -f /config/makerss_setting.py ]; then
echo "[Init] Using existing makerss_setting.py"
else
echo "[Init] New makerss_setting.py from default"
cp /makerss/makerss_setting.py /config/makerss_setting.py
if [ -n "$makerss_user" ]; then
chown "${makerss_user}":"${makerss_group}" /config/makerss_setting.py
fi
fi

echo "[Init] Starting phantomjs"
Expand Down
3 changes: 1 addition & 2 deletions root/usr/bin/makerss_run
@@ -1,6 +1,5 @@
#!/bin/sh

su - makerss -c "echo [ $(date "+%F@%T") ] Running makerss.py >> /config/makerss.log"
su - makerss -c "export PYTHONIOENCODING=utf-8; python /makerss/makerss.py"
su - makerss -c "export PYTHONIOENCODING=utf-8; cd /config && python makerss_main.py && mv *.xml /rssxml/"

exit 0

0 comments on commit 94022e0

Please sign in to comment.