Skip to content

Commit

Permalink
Issue 497: Change default port to 5001.
Browse files Browse the repository at this point in the history
  • Loading branch information
jzohrab committed Oct 20, 2024
1 parent 8feade2 commit 032ebb6
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 36 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ jobs:
# Verify with utils script back in the workspace
# (verify.py is not included in flit install)
pushd ${{ github.workspace }}
python -m utils.verify 5000
python -m utils.verify 5001
popd
pkill -f "python -m lute.main" # Kill that process.
Expand Down Expand Up @@ -257,9 +257,9 @@ jobs:
run: |
docker build -f docker/Dockerfile --build-arg INSTALL_EVERYTHING=false -t lute3 .
# Run container in the background, and check.
docker run -d -p 5000:5000 -v ./my_data:/lute_data -v ./my_backups:/lute_backup --name my-lute lute3:latest
docker run -d -p 5001:5001 -v ./my_data:/lute_data -v ./my_backups:/lute_backup --name my-lute lute3:latest
sleep 10 # Give it a moment to start.
python -m utils.verify 5000
python -m utils.verify 5001
docker stop my-lute
docker rm my-lute
Expand Down Expand Up @@ -350,4 +350,4 @@ jobs:
- name: Verify flit install
run: |
cd ${{ github.workspace }}
python -m utils.verify 5000
python -m utils.verify 5001
2 changes: 1 addition & 1 deletion README_PyPi.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pip install lute3
# Start lute
python -m lute.main
# Open your web browser to http://localhost:5000
# Open your web browser to http://localhost:5001
# When done, hit Ctl-C
# Stop the virtual environment.
Expand Down
2 changes: 1 addition & 1 deletion devstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def dev_print(s):
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Start dev server lute.")
parser.add_argument(
"--port", type=int, default=5000, help="Port number (default: 5000)"
"--port", type=int, default=5001, help="Port number (default: 5001)"
)
args = parser.parse_args()
start(args.port)
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN chmod +x /lute/install_all.sh

RUN if [ "$INSTALL_EVERYTHING" = "true" ]; then /lute/install_all.sh; fi

EXPOSE 5000
EXPOSE 5001

# Start script.
COPY docker/Dockerfile_scripts/start.sh /lute/start.sh
Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
lute:
image: lute3:latest
ports:
- 5000:5000
- 5001:5001
volumes:
# Note: you should change these directories
# to absolute paths (e.g. "/usr/yourname/etc/my_data")
Expand Down
12 changes: 6 additions & 6 deletions docker/docker_hub_overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ For more information, see the [Lute manual](https://luteorg.github.io/lute-manua
# How to use this image

```
docker run -p 5000:5000 -v <MY_DATA_PATH>:/lute_data -v <MY_BACKUP_PATH>:/lute_backup jzohrab/lute3:latest
docker run -p 5001:5001 -v <MY_DATA_PATH>:/lute_data -v <MY_BACKUP_PATH>:/lute_backup jzohrab/lute3:latest
```

Docker containers using this image writes to container directories which must be mounted from the host:
Expand All @@ -26,13 +26,13 @@ Example:
```
mkdir -p ~/lute/data
mkdir -p ~/lute/backups
docker run -p 5000:5000 -v ~/lute/data:/lute_data -v ~/lute/backups:/lute_backup --name my-lute jzohrab/lute3:latest
docker run -p 5001:5001 -v ~/lute/data:/lute_data -v ~/lute/backups:/lute_backup --name my-lute jzohrab/lute3:latest
```

The above:

* runs the container from the `jzohrab/lute3:latest` image
* exposes port 5000 on the host (so http://localhost:5000 works)
* exposes port 5001 on the host (so http://localhost:5001 works)
* mounts the necessary directories
* names the running container "my-lute"

Expand All @@ -48,15 +48,15 @@ and it prints:
Running at:
http://localhost:5000
http://localhost:5001
When you're finished reading, stop this container
with Ctrl-C, docker compose stop, or docker stop <containerid>
as appropriate.
```

(You can now open your browser to `http://localhost:5000` and start working through the Lute demo.)
(You can now open your browser to `http://localhost:5001` and start working through the Lute demo.)

With the above command, the `lutev3` process takes over that console window, so start a new console window and enter

Expand All @@ -81,7 +81,7 @@ services:
lute:
image: jzohrab/lute3:latest
ports:
- 5000:5000
- 5001:5001
volumes:
- ~/lute/data:/lute_data
- ./lute/backups:/lute_backup
Expand Down
4 changes: 2 additions & 2 deletions lute/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
User entry point.
Start lute running on given port, or 5000 if not set.
Start lute running on given port, or 5001 if not set.
e.g.
Expand Down Expand Up @@ -117,7 +117,7 @@ def start():
"Main entry point. Called via scripts and pyproject.toml."
parser = argparse.ArgumentParser(description="Start lute.")
parser.add_argument(
"--port", type=int, default=5000, help="Port number (default: 5000)"
"--port", type=int, default=5001, help="Port number (default: 5001)"
)
parser.add_argument(
"--config",
Expand Down
16 changes: 8 additions & 8 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def todos(c):
c.run("python utils/todos.py")


@task(help={"port": "optional port to run on; default = 5000"})
def start(c, port=5000):
@task(help={"port": "optional port to run on; default = 5001"})
def start(c, port=5001):
"""
Start the dev server, using script dev.py.
"""
Expand Down Expand Up @@ -83,10 +83,10 @@ def test(c):

def _site_is_running(useport=None):
"""
Return true if site is running on port, or default 5000.
Return true if site is running on port, or default 5001.
"""
if useport is None:
useport = 5000
useport = 5001

url = f"http://localhost:{useport}"
try:
Expand Down Expand Up @@ -116,7 +116,7 @@ def _site_is_running(useport=None):
)
def accept( # pylint: disable=too-many-arguments
c,
port=5000,
port=5001,
show=False,
noheadless=False,
kflag=None,
Expand All @@ -126,7 +126,7 @@ def accept( # pylint: disable=too-many-arguments
"""
Start lute, run tests/acceptance tests, screenshot fails.
If no port specified, use default 5000.
If no port specified, use default 5001.
If Lute's not running on specified port, start a server.
"""
Expand Down Expand Up @@ -174,14 +174,14 @@ def playwright(c):
"""
Start lute, run playwright tests. export SHOW=true env var to run non-headless.
Only uses port 5000.
Only uses port 5001.
If Lute's not running on specified port, start a server.
"""
run_test = ["pytest", "tests/playwright/playwright.py", "-s"]

tests_failed = False
port = 5000
port = 5001
if _site_is_running(port):
c.run(" ".join(run_test))
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/book.feature
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Feature: Books and stats are available

Scenario: I can import a url.
Given I visit "/"
Given a Spanish book from url http://localhost:5000/dev_api/fake_story.html
Given a Spanish book from url http://localhost:5001/dev_api/fake_story.html
Then the page title is Reading "Mi perro."
And the reading pane shows:
Hola/. /Tengo/ /un/ /perro/.
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/lute_test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def elapsed(self, step):
To see this data, run the acc. tests with '-s', eg:
pytest tests/acceptance/test_smoke.py --port=5000 -s
pytest tests/acceptance/test_smoke.py --port=5001 -s
"""
now = time.perf_counter()
since_start = now - self.start
Expand Down
20 changes: 10 additions & 10 deletions tests/playwright/playwright.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
Notes:
- the db must be reset to the baseline with demo stories
- site must be running (currently hardcoded to port 5000)
- site must be running (currently hardcoded to port 5001)
- start code gen in another window with `python codegen`,
then go to http://localhost:5000/ in the new window
then go to http://localhost:5001/ in the new window
- click through etc etc, then stop the code gen, copy-paste
code here, fix as needed, _then_ shut down
Expand Down Expand Up @@ -50,14 +50,14 @@ def _print(s):
page = context.new_page()

_print("Reset db.")
page.goto("http://localhost:5000/dev_api/load_demo")
page.goto("http://localhost:5001/dev_api/load_demo")

# Hardcoded port will cause problems ...
page.goto("http://localhost:5000/")
page.goto("http://localhost:5001/")

# Open Tutorial
_print("Tutorial check.")
page.goto("http://localhost:5000")
page.goto("http://localhost:5001")
page.get_by_role("link", name="Tutorial", exact=True).click()
page.locator("#ID-14-172").click()
page.frame_locator('iframe[name="wordframe"]').get_by_placeholder(
Expand All @@ -77,7 +77,7 @@ def _print(s):

# Bookmarks
_print("Bookmarks.")
page.goto("http://localhost:5000")
page.goto("http://localhost:5001")
page.get_by_role("link", name="Tutorial follow-up", exact=True).click()
page.locator(".hamburger-btn").click()
page.once("dialog", lambda dialog: dialog.accept(prompt_text="Page 1"))
Expand Down Expand Up @@ -106,7 +106,7 @@ def _print(s):

# Open and archive book.
_print("Archive.")
page.goto("http://localhost:5000")
page.goto("http://localhost:5001")
page.get_by_role("link", name="Büyük ağaç").click()
page.once("dialog", lambda dialog: dialog.accept())
page.get_by_role("link", name="Archive book").click()
Expand Down Expand Up @@ -144,7 +144,7 @@ def _print(s):

# Open term listing.
_print("Term listing.")
page.goto("http://localhost:5000/")
page.goto("http://localhost:5001/")
page.locator("#menu_terms").hover()
page.get_by_role("link", name="Terms", exact=True).click()
page.get_by_role("link", name="Hello").click()
Expand All @@ -162,7 +162,7 @@ def _print(s):

# Edit language.
_print("Edit language.")
page.goto("http://localhost:5000/")
page.goto("http://localhost:5001/")
page.locator("#menu_settings").hover()
page.get_by_role("link", name="Languages").click()
page.get_by_role("link", name="English").click()
Expand Down Expand Up @@ -225,7 +225,7 @@ def _print(s):
page.locator("#menu_books").hover()
page.get_by_role("link", name="Import web page").click()
page.get_by_label("Import URL").fill(
"http://localhost:5000/dev_api/fake_story.html"
"http://localhost:5001/dev_api/fake_story.html"
)
page.get_by_role("button", name="Import").click()
time.sleep(2)
Expand Down

0 comments on commit 032ebb6

Please sign in to comment.