Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot make SENSEI_PORT work #147

Closed
jermarchand opened this issue Apr 5, 2022 · 5 comments
Closed

Cannot make SENSEI_PORT work #147

jermarchand opened this issue Apr 5, 2022 · 5 comments
Assignees

Comments

@jermarchand
Copy link
Contributor

Hello,

How to user the variable SENSEI_PORT ?

I locally set the alias for sensei and run the command SENSEI_PORT=9080 sensei
The start logs are :

$ SENSEI_PORT=9080 sensei
latest: Pulling from zenika/sensei
...
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: http://localhost:8080/
<i> [webpack-dev-server] On Your Network (IPv4): http://172.17.0.2:8080/
...

and http://localhost:9080/ failed to open a connection.

I update the alias for sensei with :

alias sensei='docker container run \
  --pull always \
  --interactive \
  --tty \
  --rm \
  --volume $(pwd):/$(basename $(pwd)) \
  --workdir /$(basename $(pwd)) \
  --publish ${SENSEI_PORT:-8080}:8080 \  <= remove the second use of SENSEI_PORT
  --env SENSEI_PORT \
  --cap-add=SYS_ADMIN \
  zenika/sensei'

And it's possible to change the SENSEI_PORT :)

But the live reload does not work :(

Is there a solution ?

@hgwood
Copy link
Member

hgwood commented Apr 5, 2022

Hi! What's your OS? What's your shell? What's your Docker backend?

@hgwood
Copy link
Member

hgwood commented Apr 5, 2022

Looks like webpack-dev-server API has changed and start does not take the host and port like it used:

await server.start(serveOptions.port, serveOptions.host);
Therefore the port is always the default one, SENSEI_PORT is dismissed. PR incoming.

hgwood added a commit that referenced this issue Apr 5, 2022
@zigarn
Copy link
Member

zigarn commented Apr 7, 2022

There are 2 problems:

  • env var evaluation
  • sensei env var use

Env var evaluation

This form of env var definition is not taken in account in the shell command itself, only in the sub-process:

$ SENSEI_PORT=8090 echo ${SENSEI_PORT}
     # <= nothing!
$

You have to export the variable in a separate command (using export is important to be available in sub-processes, otherwise it's only in the shell):

$ export SENSEI_PORT=8090; echo ${SENSEI_PORT}
8090
$

@hgwood: this could be added in the README?

When using the second form with sensei:

$ export SENSEI_PORT=8090; sensei
Processing folder '/formation-kubernetes-user' as 'formation-kubernetes-user' using slide size 1420x800 and language 'en'
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: http://localhost:8080/
<i> [webpack-dev-server] On Your Network (IPv4): http://172.17.0.2:8080/
[...]

$ docker container ls
CONTAINER ID   IMAGE           COMMAND                  CREATED         STATUS         PORTS                                                 NAMES
1c7ea1542340   zenika/sensei   "node /app/src/cli/c…"   9 seconds ago   Up 8 seconds   8080/tcp, 0.0.0.0:8090->8090/tcp, :::8090->8090/tcp   friendly_germain

Then we hit the second issue about the sensei process not using correctly the env var.

Sensei env var use

PR #148 fixes it:

$ export SENSEI_PORT=8090; sensei
Processing folder '/formation-kubernetes-user' as 'formation-kubernetes-user' using slide size 1420x800 and language 'en'
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: http://localhost:8090/
<i> [webpack-dev-server] On Your Network (IPv4): http://172.17.0.2:8090/
[...]

$ docker container ls
CONTAINER ID   IMAGE           COMMAND                  CREATED         STATUS         PORTS                                                 NAMES
1bcefc0e2973   zenika/sensei   "node /app/src/cli/c…"   3 seconds ago   Up 3 seconds   8080/tcp, 0.0.0.0:8090->8090/tcp, :::8090->8090/tcp   wonderful_borg

@hgwood
Copy link
Member

hgwood commented Apr 11, 2022

this could be added in the README?

Sure!

hgwood added a commit that referenced this issue Apr 11, 2022
@hgwood hgwood changed the title SENSEI_PORT Cannot make SENSEI_PORT work Apr 11, 2022
@hgwood
Copy link
Member

hgwood commented Apr 11, 2022

@jermarchand I'm closing but please reopen if #148 and #150 dont fix your problem.

@hgwood hgwood closed this as completed Apr 11, 2022
@hgwood hgwood self-assigned this Apr 11, 2022
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

No branches or pull requests

3 participants