Skip to content

#3: add a script to create users and run it automatically - #7

Merged
soltysh merged 4 commits into
python:masterfrom
ezio-melotti:create-users
Mar 10, 2017
Merged

soltysh merged 4 commits into
python:masterfrom
ezio-melotti:create-users

Conversation

@ezio-melotti

Copy link
Copy Markdown
Member

This PR includes 2 changesets:

  1. add a new script that creates default users (see docstring for detauls);
  2. this script, together with rd-admin init are added to init.sh

The final result is that now, when the container is started, it will have an initialized db with 3 default users.

Comment thread image/init.sh


# initialize the db (pwd: admin) and create users
sleep 5 # wait for PG to start...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the best solution, but the other solutions I found (e.g. http://stackoverflow.com/questions/35069027/docker-wait-for-postgresql-to-be-running ) seem a bit overkill.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd still add a check if this is actually up after 5sec. so I'd go with this proposed solution:

while ! curl http://$POSTGRES_PORT_5432_TCP_ADDR:$POSTGRES_PORT_5432_TCP_PORT/ 2>&1 | grep '52'
do
  sleep 1
done

it's not big overkill and will give you confidence it's up at this point.

Comment thread image/bin/createusers.py

for user in users:
roles.append(user.capitalize())
r = ','.join(roles)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice adding a comment here, that developer has at each point user needs to have his role and all previous ones.

Comment thread image/bin/createusers.py
r = ','.join(roles)
ic = 1 if user == 'coordinator' else 0 # only coord is committer
args = ('create user username={u} address={u}@bugs.python.org '
'password=pass realname={u} github={u} roles={r} '

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't fill in github, it's not required, and might confuse. If one will be needing it, he can always set it.

Comment thread image/init.sh


# initialize the db (pwd: admin) and create users
sleep 5 # wait for PG to start...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd still add a check if this is actually up after 5sec. so I'd go with this proposed solution:

while ! curl http://$POSTGRES_PORT_5432_TCP_ADDR:$POSTGRES_PORT_5432_TCP_PORT/ 2>&1 | grep '52'
do
  sleep 1
done

it's not big overkill and will give you confidence it's up at this point.

@soltysh
soltysh merged commit fe891bd into python:master Mar 10, 2017
@ezio-melotti
ezio-melotti deleted the create-users branch March 10, 2017 21:28
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