更改Yesod端口号 [英] Change Yesod port number

查看:172
本文介绍了更改Yesod端口号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

部署Yesod网络应用,我可以将可执行文件,并配置文件以运行Yesod作为独立的Web服务器。这是目录结构。

 ├──config 
│├──client_session_key.aes
│├──favicon.ico
│├──keter.yml
│├──车型
│├──robots.txt
│├──路线
│├──设置。 yml
│├──sqlite.yml
│└──test-settings.yml
├──my-project
├──my-project.sqlite3
└──static

我尝试通过更改config / settings.yml来使用不同的端口

  port:_env:PORT:3002
批注:_env:APPROOT:http:// localhost:3002

然而,应用仍然可以通过端口3000访问。即使我删除了settings.yml,但是没有错误信息。

更改端口的方法是将环境变量 export PORT = 3002 https://github.com/yesodweb/yesod/wiki/Configuration #overriding-configuration-values-with-environment-variables ,但我不是我可以使用的。



对于开发,我可以使用 stack exec - yesod devel -p 3003 (),但我似乎没有在Yesod可执行文件(my-project)中使用 -p 选项。



为什么可执行文件没有(似乎)加载 config / settings ?如何设置在Yesod网络应用程序中使用不同的端口?

解决方案

看起来设置文件应该与可执行文件位于同一目录中。



我复制当前目录中的config / settings.yml,然后运行 ./ my_project settings.yml ,现在它正确使用3002端口。



我从 https:/ /github.com/yesodweb/yesod/issues/474


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?

解决方案

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

这篇关于更改Yesod端口号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆