Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update setup.sh #224

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Update setup.sh #224

wants to merge 5 commits into from

Conversation

Ahtidevin
Copy link

Updated setup.sh since the source from which docker was being installed expired.

Updated setup.sh
@stsievert
Copy link
Member

Thanks for the PR @Ahtidevin! Does this work when it's run, or are there still issues?

@Ahtidevin
Copy link
Author

It solved few of the problems but minion worker still does not seem to start.

@Ahtidevin
Copy link
Author

Ahtidevin commented Apr 17, 2020 via email

@stsievert
Copy link
Member

Thanks for the ping. I've launched the current master branch locally, and it launches just fine. That means the error is EC2-specific.

I'm not the biggest fan of the ec2/ directory. It's definitely outdated. If you wanted, you could launch the NEXT AMI yourself, rsync your files up and re-launch the docker machines (though you'd have to modify ami/next.sh).


If you want to resolve the issue with EC2, let's look at the an error message from your error logs:

minionworker_1 | [2020-04-13 03:25:01,493: ERROR/MainProcess] consumer: 
Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 111] Connection refused.

Again, this is EC2 specific, not NEXT.

  1. Look at this SO answer: https://stackoverflow.com/questions/50222808/celery-not-work-cannot-connect-to-amqp-guest127-0-0-15672 CELERY_BROKER_URL might need to be configured in the minionworker environment variables for docker-compose.yml.
  2. The relevant URL is configured in

    NEXT/next/constants.py

    Lines 66 to 71 in 7f604f9

    BROKER_URL = 'amqp://{user}:{password}@{hostname}:{port}/{vhost}/'.format(
    user=os.environ.get('RABBIT_ENV_RABBITMQ_USER', 'guest'),
    password=os.environ.get('RABBIT_ENV_RABBITMQ_PASS', 'guest'),
    hostname=RABBIT_HOSTNAME,
    port=RABBIT_PORT,
    vhost=os.environ.get('RABBIT_ENV_VHOST', ''))

AMQP is a message passing protocol. At first glance, this diff might solve it:

- BROKER_URL = 'amqp://{user}:{password}@{hostname}:{port}/{vhost}/'.format( 
-     vhost=os.environ.get('RABBIT_ENV_VHOST', '')) 
+ BROKER_URL = 'amqp://{user}:{password}@{hostname}:{port}/{vhost}'.format( 
+     vhost=os.environ.get('RABBIT_ENV_VHOST', '/')) 

But I'm not seeing any modification of any RABBIT_* environment variables in ec2/...

@Ahtidevin
Copy link
Author

Ahtidevin commented Apr 17, 2020 via email

@stsievert
Copy link
Member

Sounds good. Keep in mind when I say "EC2-specific" I mean "NEXT launches fine on my local machine. It seems there's a modification to some of the EC2 integration NEXT has in ec2/ going wrong".

@Ahtidevin
Copy link
Author

Ahtidevin commented Apr 17, 2020 via email

@Ahtidevin
Copy link
Author

I have a question that I came across while debugging the issue. Where in NEXT are the environment variables being set? The problem now with ec2-NEXT integration is that the port numbers are not being set. I have attached a screenshot of the environment variables in local.
Screenshot 2020-04-20 00 15 37

Thanks

@stsievert
Copy link
Member

I think they're specified in

environment:
- PYTHONUNBUFFERED=TRUE
- CELERY_SYNC_WORKER_COUNT={{CELERY_SYNC_WORKER_COUNT}}

The values that are filled are configured in

NEXT/ec2/next_ec2.py

Lines 770 to 771 in 7f604f9

docker_compose_template_vars = {
"CELERY_ON": os.getenv('CELERY_ON',True),

@Ahtidevin
Copy link
Author

Thanks for your clarification. I am able to see some variables set in these files but I am not able to see variables like the ones highlighted below being set. There seems to be a lot more variables set than what I can understand in code.
Screenshot 2020-04-20 12 11 40

@stsievert
Copy link
Member

If any of these environment variables need to be changed, I suspect they can be added in next_ec2.py and docker-compose.yml without issue. This comes after looking at how to change RabbitMQ environment variables and seeing the documentation for rabbitmq-env.conf which says

In order of preference, the startup scripts get their values from the environment, from rabbitmq-env.conf and finally from the built-in default values. For example, for the RABBITMQ_NODENAME setting, RABBITMQ_NODENAME from the environment is checked first. If it is absent or equal to the empty string, then NODENAME from rabbitmq-env.conf is checked. If it is also absent or set equal to the empty string then the default value from the startup script is used.

For example, if I wanted to change MINIONREDIS_1_PORT I'd do the following:

minionredis:
   environment:
      MINIONREDIS_1_PORT: {{MINIONREDIS_1_PORT}}
  image: redis
  ...

@Ahtidevin
Copy link
Author

Ahtidevin commented Apr 21, 2020

I am unable to see the rabbitmq-env.conf or other conf files. I can see only redis.conf.
I have one more question. For example
MINIONREDIS_PORT = int(os.environ.get('MINIONREDIS_PORT_6379_TCP_PORT', 6379))
but I cannot see a corresponding place where they set this variable. This is the case for many variables highlighted above. Thanks

@stsievert
Copy link
Member

I am unable to see the rabbitmq-env.conf or other conf files. I can see only redis.conf. ... but I cannot see a corresponding place where they set this variable.

My point: I think those environment variables can be changed, as long as they're in the environment before NEXT launches. This can be done by modifiying the environment variable in docker-compose.yml.

For example, let's say I want to change MINIONREDIS_1_PORT. I'd add os.environ.get("MINIONREDIS_1_PORT", "") to

NEXT/ec2/next_ec2.py

Lines 770 to 771 in a9b3edf

docker_compose_template_vars = {
"CELERY_ON": os.getenv('CELERY_ON',True),

I'd propagate this down to docker-compose.yml by adding an environment key to

minionredis:
image: redis
command: redis-server /next_backend/next/database/redis.conf

That is, I'd append this code:

   environment:
    MINIONREDIS_1_PORT: {{MINIONREDIS_1_PORT}}

Note: all environment variables should be strings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants