luminus-framework / luminus-template

a template project for the Luminus framework
http://www.luminusweb.net/
MIT License
647 stars 147 forks source link

"lein run" did not work with argument "--port" #528

Closed bobyuancn closed 3 years ago

bobyuancn commented 3 years ago

On Windows 10, steps to reproduce the issue:

# Create a project:
lein new luminus luminushelloworld +h2 +immutant

# change directory to the project
cd luminushelloworld

# run it in different port
lein run --port 8080

You can see it is still using port 3000.

yogthos commented 3 years ago

I'm not able to replicate this on Linux/macOS here and unfortunately don't have windows handy. You could also try using -p option or setting the port in dev-config.edn instead.

bobyuancn commented 3 years ago

It can be reproduced in WSL (v1) running Ubuntu 20.04 LTS too. Here are the console output, you can see "-p" won't help.

bobyuan@CQ45M02TXNB:~$ lein new luminus luminushelloworld +h2 +immutant
Generating a Luminus project.
bobyuan@CQ45M02TXNB:~$ cd luminushelloworld
bobyuan@CQ45M02TXNB:~/luminushelloworld$ lein run --port 8080
2021-04-18 16:43:59,503 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
2021-04-18 16:44:06,736 [main] INFO  luminushelloworld.env -
-=[luminushelloworld started successfully using the development profile]=-
2021-04-18 16:44:11,016 [main] INFO  luminus.http-server - starting HTTP server on port 3000
2021-04-18 16:44:11,158 [main] DEBUG io.undertow - starting undertow server io.undertow.Undertow@44423240
2021-04-18 16:44:11,208 [main] INFO  org.xnio - XNIO version 3.3.6.Final
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/mnt/d/bobyuan/data/maven/.m2/repository/org/jboss/xnio/xnio-nio/3.3.6.Final/xnio-nio-3.3.6.Final.jar) to constructor sun.nio.ch.EPollSelectorProvider()
WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2021-04-18 16:44:12,098 [main] DEBUG io.undertow - Configuring listener with protocol HTTP for interface 0.0.0.0 and port 3000
2021-04-18 16:44:12,296 [main] INFO  org.projectodd.wunderboss.web.Web - Registered web context /
2021-04-18 16:44:12,299 [main] INFO  luminushelloworld.nrepl - starting nREPL server on port 7000
2021-04-18 16:44:12,357 [main] INFO  luminushelloworld.core - #'luminushelloworld.db.core/*db* started
2021-04-18 16:44:12,357 [main] INFO  luminushelloworld.core - #'luminushelloworld.handler/init-app started
2021-04-18 16:44:12,358 [main] INFO  luminushelloworld.core - #'luminushelloworld.handler/app-routes started
2021-04-18 16:44:12,358 [main] INFO  luminushelloworld.core - #'luminushelloworld.core/http-server started
2021-04-18 16:44:12,358 [main] INFO  luminushelloworld.core - #'luminushelloworld.core/repl-server started
^C
bobyuan@CQ45M02TXNB:~/luminushelloworld$ lein run -p 8080
2021-04-18 16:50:11,523 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
2021-04-18 16:50:13,792 [main] INFO  luminushelloworld.env -
-=[luminushelloworld started successfully using the development profile]=-
2021-04-18 16:50:14,884 [main] INFO  luminus.http-server - starting HTTP server on port 3000
2021-04-18 16:50:14,965 [main] DEBUG io.undertow - starting undertow server io.undertow.Undertow@1764625a
2021-04-18 16:50:14,989 [main] INFO  org.xnio - XNIO version 3.3.6.Final
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/mnt/d/bobyuan/data/maven/.m2/repository/org/jboss/xnio/xnio-nio/3.3.6.Final/xnio-nio-3.3.6.Final.jar) to constructor sun.nio.ch.EPollSelectorProvider()
WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2021-04-18 16:50:15,243 [main] DEBUG io.undertow - Configuring listener with protocol HTTP for interface 0.0.0.0 and port 3000
2021-04-18 16:50:15,302 [main] INFO  org.projectodd.wunderboss.web.Web - Registered web context /
2021-04-18 16:50:15,304 [main] INFO  luminushelloworld.nrepl - starting nREPL server on port 7000
2021-04-18 16:50:15,334 [main] INFO  luminushelloworld.core - #'luminushelloworld.db.core/*db* started
2021-04-18 16:50:15,335 [main] INFO  luminushelloworld.core - #'luminushelloworld.handler/init-app started
2021-04-18 16:50:15,336 [main] INFO  luminushelloworld.core - #'luminushelloworld.handler/app-routes started
2021-04-18 16:50:15,337 [main] INFO  luminushelloworld.core - #'luminushelloworld.core/http-server started
2021-04-18 16:50:15,338 [main] INFO  luminushelloworld.core - #'luminushelloworld.core/repl-server started

As suggested, I change the port to 8080 in "dev-config.edn", and this can be a workaround.

bobyuan@CQ45M02TXNB:~/luminushelloworld$ vi dev-config.edn
bobyuan@CQ45M02TXNB:~/luminushelloworld$ cat dev-config.edn
;; WARNING
;; The dev-config.edn file is used for local environment variables, such as database credentials.
;; This file is listed in .gitignore and will be excluded from version control by Git.

{:dev true
 :port 8080
 ;; when :nrepl-port is set the application starts the nREPL server on load
 :nrepl-port 7000

 :database-url "jdbc:h2:./luminushelloworld_dev.db"}
bobyuan@CQ45M02TXNB:~/luminushelloworld$ lein run
2021-04-18 16:59:56,482 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
2021-04-18 16:59:58,899 [main] INFO  luminushelloworld.env -
-=[luminushelloworld started successfully using the development profile]=-
2021-04-18 17:00:00,109 [main] INFO  luminus.http-server - starting HTTP server on port 8080
2021-04-18 17:00:00,204 [main] DEBUG io.undertow - starting undertow server io.undertow.Undertow@5329822
2021-04-18 17:00:00,225 [main] INFO  org.xnio - XNIO version 3.3.6.Final
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/mnt/d/bobyuan/data/maven/.m2/repository/org/jboss/xnio/xnio-nio/3.3.6.Final/xnio-nio-3.3.6.Final.jar) to constructor sun.nio.ch.EPollSelectorProvider()
WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2021-04-18 17:00:00,451 [main] DEBUG io.undertow - Configuring listener with protocol HTTP for interface 0.0.0.0 and port 8080
2021-04-18 17:00:00,525 [main] INFO  org.projectodd.wunderboss.web.Web - Registered web context /
2021-04-18 17:00:00,527 [main] INFO  luminushelloworld.nrepl - starting nREPL server on port 7000
2021-04-18 17:00:00,564 [main] INFO  luminushelloworld.core - #'luminushelloworld.db.core/*db* started
2021-04-18 17:00:00,564 [main] INFO  luminushelloworld.core - #'luminushelloworld.handler/init-app started
2021-04-18 17:00:00,566 [main] INFO  luminushelloworld.core - #'luminushelloworld.handler/app-routes started
2021-04-18 17:00:00,567 [main] INFO  luminushelloworld.core - #'luminushelloworld.core/http-server started
2021-04-18 17:00:00,568 [main] INFO  luminushelloworld.core - #'luminushelloworld.core/repl-server started

But you can see, if I specify another port (9090) in command line argument, it is still no effect (still 8080).

bobyuan@CQ45M02TXNB:~/luminushelloworld$ lein run --port 9090
2021-04-18 17:01:04,396 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
2021-04-18 17:01:06,976 [main] INFO  luminushelloworld.env -
-=[luminushelloworld started successfully using the development profile]=-
2021-04-18 17:01:08,126 [main] INFO  luminus.http-server - starting HTTP server on port 8080
2021-04-18 17:01:08,248 [main] DEBUG io.undertow - starting undertow server io.undertow.Undertow@26f9165b
2021-04-18 17:01:08,289 [main] INFO  org.xnio - XNIO version 3.3.6.Final
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/mnt/d/bobyuan/data/maven/.m2/repository/org/jboss/xnio/xnio-nio/3.3.6.Final/xnio-nio-3.3.6.Final.jar) to constructor sun.nio.ch.EPollSelectorProvider()
WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2021-04-18 17:01:08,662 [main] DEBUG io.undertow - Configuring listener with protocol HTTP for interface 0.0.0.0 and port 8080
2021-04-18 17:01:08,742 [main] INFO  org.projectodd.wunderboss.web.Web - Registered web context /
2021-04-18 17:01:08,744 [main] INFO  luminushelloworld.nrepl - starting nREPL server on port 7000
2021-04-18 17:01:08,787 [main] INFO  luminushelloworld.core - #'luminushelloworld.db.core/*db* started
2021-04-18 17:01:08,788 [main] INFO  luminushelloworld.core - #'luminushelloworld.handler/init-app started
2021-04-18 17:01:08,789 [main] INFO  luminushelloworld.core - #'luminushelloworld.handler/app-routes started
2021-04-18 17:01:08,789 [main] INFO  luminushelloworld.core - #'luminushelloworld.core/http-server started
2021-04-18 17:01:08,789 [main] INFO  luminushelloworld.core - #'luminushelloworld.core/repl-server started
^C
bobyuan@CQ45M02TXNB:~/luminushelloworld$ lein run -p 9090
2021-04-18 17:05:26,129 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
2021-04-18 17:05:28,260 [main] INFO  luminushelloworld.env -
-=[luminushelloworld started successfully using the development profile]=-
2021-04-18 17:05:29,424 [main] INFO  luminus.http-server - starting HTTP server on port 8080
2021-04-18 17:05:29,511 [main] DEBUG io.undertow - starting undertow server io.undertow.Undertow@556ef86d
2021-04-18 17:05:29,528 [main] INFO  org.xnio - XNIO version 3.3.6.Final
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.xnio.nio.NioXnio$2 (file:/mnt/d/bobyuan/data/maven/.m2/repository/org/jboss/xnio/xnio-nio/3.3.6.Final/xnio-nio-3.3.6.Final.jar) to constructor sun.nio.ch.EPollSelectorProvider()
WARNING: Please consider reporting this to the maintainers of org.xnio.nio.NioXnio$2
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2021-04-18 17:05:29,742 [main] DEBUG io.undertow - Configuring listener with protocol HTTP for interface 0.0.0.0 and port 8080
2021-04-18 17:05:29,817 [main] INFO  org.projectodd.wunderboss.web.Web - Registered web context /
2021-04-18 17:05:29,819 [main] INFO  luminushelloworld.nrepl - starting nREPL server on port 7000
2021-04-18 17:05:29,854 [main] INFO  luminushelloworld.core - #'luminushelloworld.db.core/*db* started
2021-04-18 17:05:29,855 [main] INFO  luminushelloworld.core - #'luminushelloworld.handler/init-app started
2021-04-18 17:05:29,855 [main] INFO  luminushelloworld.core - #'luminushelloworld.handler/app-routes started
2021-04-18 17:05:29,856 [main] INFO  luminushelloworld.core - #'luminushelloworld.core/http-server started
2021-04-18 17:05:29,856 [main] INFO  luminushelloworld.core - #'luminushelloworld.core/repl-server started

Same to Windows, I am having latest lein, and OpenJDK.

WSL:

bobyuan@CQ45M02TXNB:~/luminushelloworld$ lein --version
Leiningen 2.9.6 on Java 11.0.10 OpenJDK 64-Bit Server VM
bobyuan@CQ45M02TXNB:~/luminushelloworld$ echo $JAVA_HOME
/usr/lib/jvm/java-11-openjdk-amd64

Win10:

D:\tmp\test2\luminushelloworld>lein --version
Leiningen 2.9.6 on Java 11.0.10 OpenJDK 64-Bit Client VM

Confirmed by my testing, this issue is not related to OS or JDK, should be possiblly a defect in Luminus 4.01 code.

yogthos commented 3 years ago

Ah found the problem, turns out that when a database profile is used then env was loaded before command line args were parsed. This update should make things work as expected. Let me know if that looks good.

bobyuancn commented 3 years ago

I confirm the problem been fixed. I am glad to catch a real bug while learning Luminus! Thank you for the quick fix, especially during weekends, so much appreciated! :-)

yogthos commented 3 years ago

And thanks for digging into this, glad we got it working. :)