jina-ai / serve

ā˜ļø Build multimodal AI applications with cloud-native stack
https://jina.ai/serve
Apache License 2.0
21.13k stars 2.22k forks source link

The server is not getting started while following the Fuzzy grep example from the docs #3662

Closed codeswithroh closed 3 years ago

codeswithroh commented 3 years ago

While following this from the docs, I noticed that the server is not getting started.

After running this piece of code

from jina import Document

with f:
    f.post('/index', (Document(text=t.strip()) for t in open(__file__) if t.strip()))  # index all lines of _this_ file
    f.block()  # block for listening request

The output is stuck at this for over 30 mins

 0/3 waiting executor0 executor1 gateway to be ready...        gateway@9557[W]:CORS is enabled. This service is now accessible from any website!
           Flow@6635[I]:šŸŽ‰ Flow is ready to use!
    šŸ”— Protocol:         HTTP
    šŸ  Local access: 0.0.0.0:12345
    šŸ”’ Private network:  192.168.43.168:12345
    šŸ’¬ Swagger UI:       http://localhost:12345/docs
    šŸ“š Redoc:        http://localhost:12345/redoc

The basic searching method is working from the Swagger UI that opens at localhost:12345 but since, the server is not completing, I am not able to create any client with this

from jina import Client, Document
from jina.types.request import Response

def print_matches(resp: Response):
    for idx, d in enumerate(resp.docs[0].matches[:3]):
        print(f'[{idx}][{d.scores["euclidian"].value:2f}:"{d.text}"')

c= Client(protocol="http", port= 12345)
c.post('/search', Document(text='Document(id=something)'), on_done= print_matches)

After running the above code, it shows pending since, the server is not being completed.

JoanFM commented 3 years ago

Hello @codeswithroh ,

I have not been able to reproduce the issue, could u give more details about the Jina version and the system u are running in?

Also some more details in the errors seen would be very helpful.

Also, it is very helpful if u can activate DEBUG logging level by setting the environment variable export JINA_LOG_LEVEL=DEBUG

codeswithroh commented 3 years ago

I am using

That is the reason why the client code shows pending and is not being executed

jina-pending-error

codeswithroh commented 3 years ago

And after setting the logging_level to DEBUG, this is the error that go printed in my console debug-1

debug-2

JoanFM commented 3 years ago

Hey @codeswithroh ,

Can u check the value of this environment variable?

JINA_LOG_CONFIG?

Also can u check the content of the file (logging.default.yml) under jina resources?

JoanFM commented 3 years ago

Also u can try to run the example by installing Jina from the version on this PR #3670 . It should get more info on the observed error

codeswithroh commented 3 years ago

This is the content given in logging.default.yml

handlers:  # enabled handlers, order does not matter
  - StreamHandler
  - FluentHandler
level: INFO  # set verbose level
configs:
  FileHandler:
    format: '%(asctime)s:{name:>15}@%(process)2d[%(levelname).1s]:%(message)s'
    output: 'jina-{uptime}.log'
    formatter: JsonFormatter
  StreamHandler:
    format: '{name:>15}@%(process)2d[%(levelname).1s]:%(message)s'
    formatter: ColorFormatter
  SysLogHandler:
    ident: # this will be prepend to all messages
    format: '{name:>15}@%(process)2d[%(levelname).1s]:%(message)s'
    host: # when not given then record it locally, /dev/log on linux /var/run/syslog on mac
    port: # when not given then record it locally,  /dev/log on linux /var/run/syslog on mac
    formatter: PlainFormatter
  FluentHandler:
    # this configuration describes where is the fluentD daemon running and waiting for logs to be emitted.
    # FluentD then will have its own configuration to forward the messages according to its own syntax
    # prefix will help fluentD filter data. This will be prepended for FluentD to easily filter incoming messages
    tag: jina
    host: 0.0.0.0
    port: 24224
    format:
      host: '%(hostname)s'
      process: '%(process)s'
      type: '%(levelname)s'

But for setting the logging_level to DEBUG I created another file named loggin_cfg.yml and the content is as follows

handlers: 
  - StreamHandler
  - SysLogHandler
  - FluentHandler
level: DEBUG
codeswithroh commented 3 years ago

Also I can't find the version of Jina mentioned in #3670. Can you mention it here?

JoanFM commented 3 years ago

This is the content given in logging.default.yml

handlers:  # enabled handlers, order does not matter
  - StreamHandler
  - FluentHandler
level: INFO  # set verbose level
configs:
  FileHandler:
    format: '%(asctime)s:{name:>15}@%(process)2d[%(levelname).1s]:%(message)s'
    output: 'jina-{uptime}.log'
    formatter: JsonFormatter
  StreamHandler:
    format: '{name:>15}@%(process)2d[%(levelname).1s]:%(message)s'
    formatter: ColorFormatter
  SysLogHandler:
    ident: # this will be prepend to all messages
    format: '{name:>15}@%(process)2d[%(levelname).1s]:%(message)s'
    host: # when not given then record it locally, /dev/log on linux /var/run/syslog on mac
    port: # when not given then record it locally,  /dev/log on linux /var/run/syslog on mac
    formatter: PlainFormatter
  FluentHandler:
    # this configuration describes where is the fluentD daemon running and waiting for logs to be emitted.
    # FluentD then will have its own configuration to forward the messages according to its own syntax
    # prefix will help fluentD filter data. This will be prepended for FluentD to easily filter incoming messages
    tag: jina
    host: 0.0.0.0
    port: 24224
    format:
      host: '%(hostname)s'
      process: '%(process)s'
      type: '%(levelname)s'

But for setting the logging_level to DEBUG I created another file named loggin_cfg.yml and the content is as follows

handlers: 
  - StreamHandler
  - SysLogHandler
  - FluentHandler
level: DEBUG

Ok, to set the DEBUG log level u just need to run a cell in ur notebook setting os.environ["JINA_LOG_LEVEL"]=True and that should be enough, no need to create any extra file.

The error u show is related to the file u created, so I cannot get better information from the DEBUGlevel.

Alternatively u can change the DEBUG LEVEL directly in the logging.default.yml file

bwanglzu commented 3 years ago

i managed to use the same code as your's running on notebook, can not reproduce the above error.

note: since __file__ is missing in jupyter, i changed it to the current file

3F28B22D-0A73-401F-9265-B280632B8A78 325458B5-0202-4019-B49F-F19E5FCBFB48