development.ini in a multi-user environment?

41 views
Skip to first unread message

Jamie B.

unread,
Mar 4, 2012, 10:43:40 PM3/4/12
to pylons-discuss
Hello --

When an app is started, it binds to whatever IP address and port
number is specified in development.ini. How would you handle this on
a multi-user computer where several developers are working
simultaneously via remote X sessions? They all can't bind to the same
IP/port.

Each developer could obviously manually change this before launching
the HTTP daemon. But that's a pain to do each time. Or each
developer could have their own .ini file. But then important config
changes aren't shared between them during SVN commits. I've been
playing around with some iptables rules, but I don't think it's going
to work as I need it to. Is there a way I can use environment
variables in development.ini? Or does anyone have any other
suggestions? Thanks.

John Anderson

unread,
Mar 4, 2012, 11:16:47 PM3/4/12
to pylons-...@googlegroups.com
Change your development.ini to have:
 port = %(port)s

and then have your developers do:
pserve ./development.ini port=8080


Jamie B.

unread,
Mar 5, 2012, 12:13:48 AM3/5/12
to pylons-discuss


On Mar 4, 11:16 pm, John Anderson <son...@gmail.com> wrote:
Thanks, John. I was hoping for an elegant solution like that.

John Anderson

unread,
Mar 5, 2012, 12:45:53 AM3/5/12
to pylons-...@googlegroups.com

> > Hello --
>
> > When an app is started, it binds to whatever IP address and port
> > number is specified in development.ini.  How would you handle this on
> > a multi-user computer where several developers are working
> > simultaneously via remote X sessions?  They all can't bind to the same
> > IP/port.
>
> > Each developer could obviously manually change this before launching
> > the HTTP daemon.  But that's a pain to do each time.  Or each
> > developer could have their own .ini file.  But then important config
> > changes aren't shared between them during SVN commits.  I've been
> > playing around with some iptables rules, but I don't think it's going
> > to work as I need it to. Is there a way I can use environment
> > variables in development.ini?  Or does anyone have any other
> > suggestions? Thanks.
>
> Change your development.ini to have:
>  port = %(port)s
>
> and then have your developers do:
> pserve ./development.ini port=8080

Thanks, John.  I was hoping for an elegant solution like that.


As an alternative, if your team is using bash, they could define an alias in their bashrc:

 alias run="pserve ./development.ini http_port=$(lsof -i -P | awk '/pserve/ {split($9, a, /:/); print a[2] + 1; f = 1} END {if (!f) print "6543"}')"

and in your development.ini
port = %(http_port)s

and then they would just be able to type 'run' in the directory and it would do the rest.

John Anderson

unread,
Mar 5, 2012, 12:55:47 AM3/5/12
to pylons-...@googlegroups.com
That one had a small bug, here is your final alias ;)

alias run="pserve ./development.ini http_port=$(lsof -i -P | grep pserve | awk '{split($9, a, /:/); print a[2]; f = 1} END {if (!f) print "6543"}'|sort|tail -1|awk '{print $0+1 }')"

Mike Orr

unread,
Mar 5, 2012, 10:48:53 PM3/5/12
to pylons-...@googlegroups.com
On Sun, Mar 4, 2012 at 7:43 PM, Jamie B. <jjb...@rightbrainnetworks.com> wrote:
> Or each
> developer could have their own .ini file.  But then important config
> changes aren't shared between them during SVN commits.  ... Is there a way I can use environment

> variables in development.ini?  Or does anyone have any other
> suggestions? Thanks.

You can also have one config file read another and override just the
changed variables. From Pylons test.ini:

===
[app:main]
use = config:development.ini

# Add additional test specific configuration options as necessary.
===

--
Mike Orr <slugg...@gmail.com>

Reply all
Reply to author
Forward
0 new messages