Skip to content

Commit

Permalink
Merge pull request #987 from fishtown-analytics/feature/dbt-docs-serv…
Browse files Browse the repository at this point in the history
…e-port

add --port parameter to "dbt docs serve" (#955)
  • Loading branch information
beckjake authored Sep 11, 2018
2 parents be54123 + 957115e commit 669a29b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions dbt/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,12 @@ def parse_args(args):
seed_sub.set_defaults(cls=seed_task.SeedTask, which='seed')

serve_sub = docs_subs.add_parser('serve', parents=[base_subparser])
serve_sub.add_argument(
'--port',
default=8080,
type=int,
help='Specify the port number for the docs server.'
)
serve_sub.set_defaults(cls=serve_task.ServeTask,
which='serve')

Expand Down
8 changes: 5 additions & 3 deletions dbt/task/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ class ServeTask(RunnableTask):
def run(self):
os.chdir(self.project['target-path'])

port = 8080
port = self.args.port

shutil.copyfile(DOCS_INDEX_FILE_PATH, 'index.html')

logger.info("Serving docs at 0.0.0.0:{}".format(port))
logger.info(
"To access from your browser, navigate to http://localhost:8080.")
"To access from your browser, navigate to http://localhost:{}."
.format(port)
)
logger.info("Press Ctrl+C to exit.\n\n")

httpd = TCPServer(
Expand All @@ -29,7 +31,7 @@ def run(self):
)

try:
webbrowser.open_new_tab('http://127.0.0.1:8080')
webbrowser.open_new_tab('http://127.0.0.1:{}'.format(port))
except webbrowser.Error as e:
pass

Expand Down

0 comments on commit 669a29b

Please sign in to comment.