Change Yesod port number

2019-08-08 04:25发布

From Deploying Yesod web app, I could copy the executable, static, and config file to run Yesod as a standalone web server. This is the directory structure.

├── config
│   ├── client_session_key.aes
│   ├── favicon.ico
│   ├── keter.yml
│   ├── models
│   ├── robots.txt
│   ├── routes
│   ├── settings.yml
│   ├── sqlite.yml
│   └── test-settings.yml
├── my-project
├── my-project.sqlite3
└── static

I tried to use different port by changing config/settings.yml

port:           "_env:PORT:3002"
approot:        "_env:APPROOT:http://localhost:3002"

However, the app is still accessible with port 3000. Even I removed the settings.yml, but there was no error message.

The way to change the port was from changing the environment variables export PORT=3002 from https://github.com/yesodweb/yesod/wiki/Configuration#overriding-configuration-values-with-environment-variables, but I it's not what I can use.

For development I can use stack exec -- yesod devel -p 3003 (how can I change the settings (e.g., port) used by "yesod devel"?), but I don't seem to use the -p option with the Yesod executable (my-project).

Why the executable does not (seem to) load config/settings? How to setup to use different port in Yesod web app?

标签: haskell yesod
1条回答
▲ chillily
2楼-- · 2019-08-08 04:39

It looks like that the setting file should be in the same directory as the executable.

I copied config/settings.yml in current directory, then run the ./my_project settings.yml, now it uses the 3002 port correctly.

I have some hints from https://github.com/yesodweb/yesod/issues/474

查看更多
登录 后发表回答