Change Yesod port number

邮差的信 提交于 2019-12-11 11:53:11

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/33658641/change-yesod-port-number

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!