728x90
반응형

다음과 같이 각 서버에 Fluentd를 설치해 수집하는 서버로 로그를 전송하고

 

Kafka를 일종의 버퍼로 하여 ELK 스택이나 다른 것들을 이용할 수 있도록 구성했다.

각 서버에서 tail로 로그 파일을 읽어서 forward로 송/수신하고 있었는데

 

이 과정에서 다음과 같은 에러가 발생하며 누락 혹은 지연되는 경우가 발생했다.

[warn]: #0 failed to flush the buffer. retry_time=0 next_retry_seconds=... chunk="..." error_class=Fluent::Plugin::ForwardOutput::NoNodesAvailable error="no nodes are available"

worker를 늘려 보기도 하고 버퍼 설정을 바꿔보기도 했지만 위의 에러는 계속 나왔다.

 

원인이 무엇인지 한동안 못찾다가 UDP 방화벽을 열어줘야한다는 글을 봤다.

 

그래서 문서를 보니 forward 통신을 할 때 heartbeat을 보내는 설정이 있었다.

 

transport가 기본값이라 tcp로 바꿔보니 해당 에러가 더이상 나지 않았다.

 

(아마도 기본값인 경우 udp로도 전송하는데 막혀있어 에러가 난 것으로 생각된다.)

 

하지만 1초(기본값)마다 heartbeat을 보내서 로그 전송 속도가 눈에 띄게 줄었다.

 

heartbeat을 굳이 필요없어 none으로 하니 속도가 빨라진 것을 확인할 수 있었다.

 

참고 문헌

  1. https://qiita.com/kentokento/items/60b6654d4eea1dad5f42

  2. https://docs.fluentd.org/output/forward#heartbeat_type

반응형

'Log' 카테고리의 다른 글

[Log] Airflow 설치  (0) 2020.03.12
[Log] Zeppelin 설치 및 Spark 연동  (0) 2020.03.05
[Log] Spark ElasticSearch Parquet  (0) 2020.01.25
[Log] Logstash Kafka 연동 에러 해결  (0) 2020.01.25
[Log] Logstash Pipeline 사용하기  (0) 2020.01.25
728x90
반응형

React Native 버전을 0.59에서 0.61로 업데이트하면서 Hermes를 사용해보기로 했다.

 

Hermes 설정을 완료하고 앱을 구동했으나 다음과 같은 에러가 발생했다.

RangeError: Maximum call stack size exceeded, js engine:hermes

릴리스 버전으로 빌드를 시도해봤지만 메모리 문제로 빌드가 되지 않았다.

gradle emitting JVM memory status event {Maximum: 1431830528, Committed: 434634752}

이유가 무엇인지 찾아보니 앱에서 JSON 파일을 사용하고 있었는데 이 파일이 너무 커서 생긴 문제였다.

 

이 문제를 해결하기 위해 Hermes를 안쓰고 해봤지만 앱 사이즈가 0.59 일 때보다 커졌다.

 

그래서 Hermes를 쓰면서 동작하게 할 수 있는 방법을 찾다가 SQLite를 사용하기로 했다.

 

여러 라이브러리가 있지만 react-native-sqlite-storage를 이용했다.

 

android/src/main/assets/data 로 디렉토리를 만들고 파일을 넣는다.

다음과 같이 하면 만든 DB 파일에 쉽게 접근할 수 있었다.

import SQLite from 'react-native-sqlite-storage';

class App extends Component {
  constructor() {
    super();
    const db = SQLite.openDatabase({
      name: 'test.db',
      location: 'deault',
      createFromLocation: '~data/test.db'
    },
    () => {},
    error => console.log(err));

    this.state = {
      db,
      data: []
    }
  }

  componentWillUnmount() {
    const { db } = this.state;
    db.close();
  }

  componentDidMount() {
    const { db } = this.state;

    db.transaction(tx => {
      tx.executeSql('SELECT * FROM test;', [], (tx, results) => {
        const rows = results.rows;
        const data = rows.raw().map(v => v);

        this.setState({ data });
      });
    });
  }

  ...
}
$  npm install react-native-sqlite-storage

하지만 위와 같이 설치하면 되는데 막상 구동시켜보면 아래와 같은 에러가 나왔다.

java.lang.NoSuchMethodError: No interface method pushMap

다음과 같이 패치가 된 것을 설치하면 더이상 java.lang.NoSuchMethodError는 나오지 않았다.

$ npm install react-native-sqlite-storage@andpor/react-native-sqlite-storage#pull/405/head

 

참고 문헌

  1. https://github.com/facebook/hermes/issues/135

  2. https://dev-yakuza.github.io/ko/react-native/react-native-sqlite-storage/

  3. https://github.com/andpor/react-native-sqlite-storage

  4. https://github.com/andpor/react-native-sqlite-storage/issues/387#issuecomment-575307816

반응형
728x90
반응형

mp3 파일들을 연속으로 재생할 수 있는 웹페이지를 만들었다.

 

처음엔 단순하게 audio 태그를 이용하여 재생했다.

 

데스크톱에서 확인했을 때 잘 동작해서 문제가 없다고 생각했다.

 

그런데 모바일에서 확인해보니 처음 재생은 화면이 꺼져도 끝까지 잘 됐지만 다음 파일이 재생되지 않았다.

 

그래서 화면이 꺼지든가 브라우저가 백그라운드로 가도 재생이 되도록 해보려고 방법을 찾아봤다.

 

그러다가 PWA로 하면 원하는 기능이 되지 않을까 해서 찾아봤다.

 

찾아보니 PWA로 만든 음악 플레이어가 있어서 가능성이 보여 예제를 찾아 만들어 보기로 했다.

 

다음은 예제 코드를 참고하여 간단하게 PWA를 만든 코드 일부분이다.

 

manifest.json 파일을 만들어서 추가한다.

 

홈 화면에 추가했을 때 아이콘과 스플래시 화면이 나오도록 설정할 수 있다.

{
  "description": "Play mp3 files.",
  "display": "standalone",
  "icons": [
    {
      "src": "icon/icon-64.png",
      "sizes": "64x64",
      "type": "image/png"
    }
  ],
  "name": "PWA Test",
  "short_name": "PWA Test",
  "start_url": "/index.html",
  "background_color": "#3367D6",
  "theme_color": "#3367D6"
}

그리고 Service Worker를 등록하면 된다.

 

Service Worker는 브라우저가 백그라운드에서 실행하는 스크립트로 웹페이지와는 별개로 작동하며

 

웹페이지 또는 사용자 상호작용이 필요하지 않은 기능을 사용할 수 있게 해준다.

 

index.htmlService Worker를 등록하는 코드를 추가한다.

...
<head>
  <link rel="manifest" href="/manifest.json">
  <link rel="apple-touch-icon" sizes="180x180" href="/icons/icon-64.png">
</head>
<body>
  <script type="text/javascript">
    if('serviceWorker' in navigator) {
      navigator.serviceWorker
               .register('/pwa-examples/a2hs/sw.js')
               .then(function() { console.log('Service Worker Registered'); });
    }
  </script>
</body>
...

sw.js 파일에 다음 코드를 추가한다.

self.addEventListener('install', function(e) {
  e.waitUntil(
    caches.open('cache').then(function(cache) {
      return cache.addAll([
        '/',
        '/index.html',
        '/script.js',
        '/style.css',
        '/icon.png'
      ]);
    });
  );
});

self.addEventListener('fetch', function(e) {
  e.respondWith(
    caches.match(e.request).then(function(response) {
      return response || fetch(e.request);
    });
  );
});

iOS에서 사파리로 접속한 다음 _홈 화면에 추가_를 하면 설정한 아이콘 모양으로 홈 화면에 추가된다.

 

화면이 꺼지거나 앱을 종료해도 재생이 되는지 테스트했지만 재생이 되지 않았다.

 

하지만 안드로이드에서는 화면이 꺼지거나 앱을 꺼도 재생이 잘되는 것을 확인할 수 있었다.

 

참고 문헌

  1. https://github.com/mdn/pwa-examples

  2. https://developers.google.com/web/fundamentals/web-app-manifest

  3. https://developers.google.com/web/fundamentals/primers/service-workers?hl=ko

반응형
728x90
반응형

시스템 환경설정 > 개인 정보 보호 > 전체 디스크 접근 권한에 Emacs 앱을 추가했지만

홈 디렉토리를 제외한 문서, 다운로드 등의 디렉토리 접근이 불가능했다.

 

이유는 Emacs가 ruby로 실행되기 때문이었다.

 

전체 디스크 접근 권한/usr/bin/ruby를 추가하면 모든 디렉토리에 접근할 수 있다.

Emacs is built on various versions of Mac OS X: 10.6, 10.7 and 10.9 as of this writing.
The 10.6 builds also build 32-bit and PowerPC binaries
(only Emacs 24 builds PowerPC—Emacs dropped support for it in Emacs 25).
The later OSes only build 64-bit builds.
All the binaries are combined into a single executable
and a small Ruby launcher chooses which binary to run
based on the machine's OS and architecture.

usr 디렉토리가 안보이는 경우 Command + Shift + .을 입력하면 숨겨진 디렉토리가 나온다.

 

참고 문헌

  1. https://emacs.stackexchange.com/questions/53026/how-to-restore-file-system-access-in-macos-catalina

  2. https://github.com/caldwell/build-emacs/blob/master/launch.rb

반응형

+ Recent posts