1👍
✅
Farbic functions allow you to use arguments:
@task #not bad to use once your fabfile is big by using helper functions
def runserver(project_path, port=8000):
run("python %s/manage.py runserver 0.0.0.0:%s" % (project_path,port))
and you would use it like this:
fab runserver:/home/project,8080
you could also simplify it by creating a task that selects a port per project, although all available projects and their paths would have to be defined there. Then it could be as easy as:
fab runserver:myprojectname
Of course you could additionally implement @morgan’s answer making the script check if the port is open and automatically assign a free one.
0👍
You could use the socket module, as shown here and have the os figure out your port, and then fabric just let you know which it chose.
- [Answer]-When I submit a form it goes to unknown url
- [Answer]-Django chaining multiple queries together to return latest
Source:stackexchange.com