Git Product home page Git Product logo

reddit's Introduction

Monolith application

Deploy using Capistrano

Requirements for the target host:

  • Ruby (>2.2.0) installed via rvm
  • MongDB
  • ports 22 and 9292 should be reachable by you

Steps:

  1. Install required gems: bundle install
  2. Set env vars:
export SERVER_IP=<ip_address>   # public IP address of the target host
export REPO_NAME=<account/name> # repo name to fetch the code from, e.g. Artemmkin/reddit
export DEPLOY_USER=deploy       # username used to connect via SSH
  1. Deploy using capistrano:
bundle exec cap production deploy:initial

reddit's People

Contributors

7even avatar artemmkin avatar serjs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

reddit's Issues

Метрики ui не отдаются, если исходник взят из github.

Установка метрик завязана на файл build_info.txt.

if File.exist?('build_info.txt')
  build_info=File.readlines('build_info.txt')

  scheduler = Rufus::Scheduler.new

  scheduler.every '3s' do
    check = JSON.parse(healthcheck(post_service_host, post_service_port, comment_service_host, comment_service_port))
    ui_health_gauge.set({ version: check['version'], commit_hash: build_info[0].strip, branch: build_info[1].strip }, check['status'])
    ui_health_post_gauge.set({ version: check['version'], commit_hash: build_info[0].strip, branch: build_info[1].strip }, check['dependent_services']['post'])
    ui_health_comment_gauge.set({ version: check['version'], commit_hash: build_info[0].strip, branch: build_info[1].strip }, check['dependent_services']['comment'])
  end
end

Файл создаётся при выполнении скрипта сборки контейнера docker_build.sh для того, чтобы Prometheus в лейбл метрике вывел ветку и обрезанный хэш коммита.

echo `git show --format="%h" HEAD | head -1` > build_info.txt
echo `git rev-parse --abbrev-ref HEAD` >> build_info.txt

Соответственно, если собрать контейнер скриптом, а затем в контейнер подключить volume с исходником приложения из git, метрики в Prometheus не появятся.

Я предполагаю, что логика должна быть следующей:
Метрики устанавливать в любом случае, но при отсутствии файла в качестве номера билда выводить внятные заглушки типа no_build_info. Вообще убирать лейблы в этом случае, я думаю, не стоит, т.к. не будет понятно, почему их нет.

Приложение `post` падает при отсутствии zipkin

Hw#25

{
  "_index": "fluentd-20180519",
  "_type": "access_log",
  "_id": "AWN46ikOv3Yq8u2uH3xC",
  "_score": 1,
  "_source": {
    "log": "{\"event\": \"internal_error\", \"level\": \"error\", \"method\": \"GET\", \"path\": \"/posts?\", \"remote_addr\": \"172.18.0.3\", \"request_id\": \"d6f9abe5-afbd-4459-9964-4376481b4170\", \"service\": \"post\", \"timestamp\": \"2018-05-19 15:00:01\", \"traceback\": \"Traceback (most recent call last):\\n  File \\\"/usr/local/lib/python3.6/site-packages/urllib3/connection.py\\\", line 141, in _new_conn\\n    (self.host, self.port), self.timeout, **extra_kw)\\n  File \\\"/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py\\\", line 60, in create_connection\\n    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):\\n  File \\\"/usr/local/lib/python3.6/socket.py\\\", line 743, in getaddrinfo\\n    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):\\nsocket.gaierror: [Errno -2] Name does not resolve\\n\\nDuring handling of the above exception, another exception occurred:\\n\\nTraceback (most recent call last):\\n  File \\\"/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py\\\", line 601, in urlopen\\n    chunked=chunked)\\n  File \\\"/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py\\\", line 357, in _make_request\\n    conn.request(method, url, **httplib_request_kw)\\n  File \\\"/usr/local/lib/python3.6/http/client.py\\\", line 1239, in request\\n    self._send_request(method, url, body, headers, encode_chunked)\\n  File \\\"/usr/local/lib/python3.6/http/client.py\\\", line 1285, in _send_request\\n    self.endheaders(body, encode_chunked=encode_chunked)\\n  File \\\"/usr/local/lib/python3.6/http/client.py\\\", line 1234, in endheaders\\n    self._send_output(message_body, encode_chunked=encode_chunked)\\n  File \\\"/usr/local/lib/python3.6/http/client.py\\\", line 1026, in _send_output\\n    self.send(msg)\\n  File \\\"/usr/local/lib/python3.6/http/client.py\\\", line 964, in send\\n    self.connect()\\n  File \\\"/usr/local/lib/python3.6/site-packages/urllib3/connection.py\\\", line 166, in connect\\n    conn = self._new_conn()\\n  File \\\"/usr/local/lib/python3.6/site-packages/urllib3/connection.py\\\", line 150, in _new_conn\\n    self, \\\"Failed to establish a new connection: %s\\\" % e)\\nurllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x7f4fc4860358>: Failed to establish a new connection: [Errno -2] Name does not resolve\\n\\nDuring handling of the above exception, another exception occurred:\\n\\nTraceback (most recent call last):\\n  File \\\"/usr/local/lib/python3.6/site-packages/requests/adapters.py\\\", line 440, in send\\n    timeout=timeout\\n  File \\\"/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py\\\", line 639, in urlopen\\n    _stacktrace=sys.exc_info()[2])\\n  File \\\"/usr/local/lib/python3.6/site-packages/urllib3/util/retry.py\\\", line 388, in increment\\n    raise MaxRetryError(_pool, url, error or ResponseError(cause))\\nurllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='zipkin', port=9411): Max retries exceeded with url: /api/v1/spans (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f4fc4860358>: Failed to establish a new connection: [Errno -2] Name does not resolve',))\\n\\nDuring handling of the above exception, another exception occurred:\\n\\nTraceback (most recent call last):\\n  File \\\"/usr/local/lib/python3.6/site-packages/flask/app.py\\\", line 1612, in full_dispatch_request\\n    rv = self.dispatch_request()\\n  File \\\"/usr/local/lib/python3.6/site-packages/flask/app.py\\\", line 1598, in dispatch_request\\n    return self.view_functions[rule.endpoint](**req.view_args)\\n  File \\\"post_app.py\\\", line 96, in posts\\n    posts = find_posts()\\n  File \\\"/usr/local/lib/python3.6/site-packages/py_zipkin/zipkin.py\\\", line 296, in __exit__\\n    self.stop(_exc_type, _exc_value, _exc_traceback)\\n  File \\\"/usr/local/lib/python3.6/site-packages/py_zipkin/zipkin.py\\\", line 314, in stop\\n    self.logging_context.stop()\\n  File \\\"/usr/local/lib/python3.6/site-packages/py_zipkin/logging_helper.py\\\", line 76, in stop\\n    self.log_spans()\\n  File \\\"/usr/local/lib/python3.6/site-packages/py_zipkin/logging_helper.py\\\", line 185, in log_spans\\n    transport_handler=self.transport_handler,\\n  File \\\"/usr/local/lib/python3.6/site-packages/py_zipkin/logging_helper.py\\\", line 325, in log_span\\n    transport_handler(message)\\n  File \\\"post_app.py\\\", line 55, in http_transport\\n    headers={'Content-Type': 'application/x-thrift'})\\n  File \\\"/usr/local/lib/python3.6/site-packages/requests/api.py\\\", line 112, in post\\n    return request('post', url, data=data, json=json, **kwargs)\\n  File \\\"/usr/local/lib/python3.6/site-packages/requests/api.py\\\", line 58, in request\\n    return session.request(method=method, url=url, **kwargs)\\n  File \\\"/usr/local/lib/python3.6/site-packages/requests/sessions.py\\\", line 508, in request\\n    resp = self.send(prep, **send_kwargs)\\n  File \\\"/usr/local/lib/python3.6/site-packages/requests/sessions.py\\\", line 618, in send\\n    r = adapter.send(request, **kwargs)\\n  File \\\"/usr/local/lib/python3.6/site-packages/requests/adapters.py\\\", line 508, in send\\n    raise ConnectionError(e, request=request)\\nrequests.exceptions.ConnectionError: HTTPConnectionPool(host='zipkin', port=9411): Max retries exceeded with url: /api/v1/spans (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f4fc4860358>: Failed to establish a new connection: [Errno -2] Name does not resolve',))\\n\"}",
    "container_id": "2ece463ebd7f7345becf89e01a70efb554248b499acfb440756d60bc8717ee33",
    "container_name": "/docker_post_1",
    "source": "stdout",
    "@timestamp": "2018-05-19T15:00:01+00:00",
    "@log_name": "service.post"
  },
  "fields": {
    "@timestamp": [
      1526742001000
    ]
  }
}

Брэнч logging: Не стартует сервис comment

При выполнении dokcer-compose up -d, сервис comment падает с ошибкой

Логи

Attaching to docker_comment_1
comment_1  | Puma starting in single mode...
comment_1  | * Version 3.10.0 (ruby 2.2.10-p489), codename: Russell's Teapot
comment_1  | * Min threads: 0, max threads: 16
comment_1  | * Environment: development
comment_1  | ! Unable to load application: TZInfo::DataSourceNotFound: No source of timezone data could be found.
comment_1  | Please refer to http://tzinfo.github.io/datasourcenotfound for help resolving this error.
comment_1  | /usr/local/bundle/gems/tzinfo-1.2.3/lib/tzinfo/data_source.rb:182:in `rescue in create_default_data_source': No source of timezone data could be found. (TZInfo::DataSourceNotFound)
comment_1  | Please refer to http://tzinfo.github.io/datasourcenotfound for help resolving this error.
comment_1  |    from /usr/local/bundle/gems/tzinfo-1.2.3/lib/tzinfo/data_source.rb:179:in `create_default_data_source'
comment_1  |    from /usr/local/bundle/gems/tzinfo-1.2.3/lib/tzinfo/data_source.rb:40:in `block in get'
comment_1  |    from /usr/local/bundle/gems/tzinfo-1.2.3/lib/tzinfo/data_source.rb:39:in `synchronize'
comment_1  |    from /usr/local/bundle/gems/tzinfo-1.2.3/lib/tzinfo/data_source.rb:39:in `get'
comment_1  |    from /usr/local/bundle/gems/tzinfo-1.2.3/lib/tzinfo/timezone.rb:661:in `data_source'
comment_1  |    from /usr/local/bundle/gems/tzinfo-1.2.3/lib/tzinfo/timezone.rb:130:in `all_identifiers'
comment_1  |    from /usr/local/bundle/gems/tzinfo-1.2.3/lib/tzinfo/timezone.rb:124:in `all'
comment_1  |    from /usr/local/bundle/gems/et-orbi-1.0.8/lib/et-orbi.rb:687:in `determine_local_tzones'
comment_1  |    from /usr/local/bundle/gems/et-orbi-1.0.8/lib/et-orbi.rb:626:in `determine_local_tzone'
comment_1  |    from /usr/local/bundle/gems/et-orbi-1.0.8/lib/et-orbi.rb:171:in `local_tzone'
comment_1  |    from /usr/local/bundle/gems/et-orbi-1.0.8/lib/et-orbi.rb:147:in `get_tzone'
comment_1  |    from /usr/local/bundle/gems/et-orbi-1.0.8/lib/et-orbi.rb:275:in `get_tzone'
comment_1  |    from /usr/local/bundle/gems/et-orbi-1.0.8/lib/et-orbi.rb:303:in `initialize'
comment_1  |    from /usr/local/bundle/gems/et-orbi-1.0.8/lib/et-orbi.rb:19:in `new'
comment_1  |    from /usr/local/bundle/gems/et-orbi-1.0.8/lib/et-orbi.rb:19:in `now'
comment_1  |    from /usr/local/bundle/gems/et-orbi-1.0.8/lib/et-orbi.rb:265:in `now'
comment_1  |    from /usr/local/bundle/gems/rufus-scheduler-3.4.2/lib/rufus/scheduler.rb:543:in `start'
comment_1  |    from /usr/local/bundle/gems/rufus-scheduler-3.4.2/lib/rufus/scheduler.rb:89:in `initialize'
comment_1  |    from /app/comment_app.rb:49:in `new'
comment_1  |    from /app/comment_app.rb:49:in `<top (required)>'
comment_1  |    from config.ru:1:in `require'
comment_1  |    from config.ru:1:in `block in <main>'
comment_1  |    from /usr/local/bundle/gems/rack-2.0.5/lib/rack/builder.rb:55:in `instance_eval'
comment_1  |    from /usr/local/bundle/gems/rack-2.0.5/lib/rack/builder.rb:55:in `initialize'
comment_1  |    from config.ru:in `new'
comment_1  |    from config.ru:in `<main>'
comment_1  |    from /usr/local/bundle/gems/rack-2.0.5/lib/rack/builder.rb:49:in `eval'
comment_1  |    from /usr/local/bundle/gems/rack-2.0.5/lib/rack/builder.rb:49:in `new_from_string'
comment_1  |    from /usr/local/bundle/gems/rack-2.0.5/lib/rack/builder.rb:40:in `parse_file'
comment_1  |    from /usr/local/bundle/gems/puma-3.10.0/lib/puma/configuration.rb:314:in `load_rackup'
comment_1  |    from /usr/local/bundle/gems/puma-3.10.0/lib/puma/configuration.rb:243:in `app'
comment_1  |    from /usr/local/bundle/gems/puma-3.10.0/lib/puma/runner.rb:138:in `load_and_bind'
comment_1  |    from /usr/local/bundle/gems/puma-3.10.0/lib/puma/single.rb:87:in `run'
comment_1  |    from /usr/local/bundle/gems/puma-3.10.0/lib/puma/launcher.rb:183:in `run'
comment_1  |    from /usr/local/bundle/gems/puma-3.10.0/lib/puma/cli.rb:77:in `run'
comment_1  |    from /usr/local/bundle/gems/puma-3.10.0/bin/puma:10:in `<top (required)>'
comment_1  |    from /usr/local/bundle/bin/puma:29:in `load'
comment_1  |    from /usr/local/bundle/bin/puma:29:in `<main>'

Решение - добавить gem 'tzinfo-data' в Gemfile

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.