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

[Bug]: Geting current user failed! #575

Closed
YueMiyuki opened this issue Feb 25, 2023 · 14 comments · Fixed by #576 or #579
Closed

[Bug]: Geting current user failed! #575

YueMiyuki opened this issue Feb 25, 2023 · 14 comments · Fixed by #576 or #579

Comments

@YueMiyuki
Copy link
Contributor

问题描述

服务报错 Geting current user failed! 并且配置文件无法加载

image

是否已搜索同类问题

已搜索,但未能解决

操作系统

Linux

架构

x86_64

ddns-go 版本

4.5.4

安装方式

服务

额外信息

No response

@YueMiyuki
Copy link
Contributor Author

更新:不使用服务可以正常加载

@jeessy2
Copy link
Owner

jeessy2 commented Feb 25, 2023

不管这个报错。运行为服务,找不到HOME目录,所以有这个提示。不影响你使用

@YueMiyuki
Copy link
Contributor Author

配置文件加载不上去了 系统是fedora

@WaterLemons2k
Copy link
Contributor

看起来像是服务指定了错误的配置文件(./.ddns_go_config.yaml)导致 Geting current user failed!,把 ddns-go 服务配置文件(/etc/systemd/system/ddns-go.serviceExecStart 行的 -c 选项去掉看看。

@jeessy2
Copy link
Owner

jeessy2 commented Feb 26, 2023

重新安装服务,重新看下-c目录,或者安装的时候指定-c路径

@YueMiyuki
Copy link
Contributor Author

image

@YueMiyuki
Copy link
Contributor Author

使用绝对路径依然报错
image

@YueMiyuki
Copy link
Contributor Author

YueMiyuki commented Feb 26, 2023

看起来像是服务指定了错误的配置文件(./.ddns_go_config.yaml)导致 Geting current user failed!,把 ddns-go 服务配置文件(/etc/systemd/system/ddns-go.serviceExecStart 行的 -c 选项去掉看看。

配置文件的路径看起来并没有问题

image

@YueMiyuki
Copy link
Contributor Author

重新安装服务,重新看下-c目录,或者安装的时候指定-c路径

安装的时候有指定正确 -c 路径:
image

@YueMiyuki
Copy link
Contributor Author

/etc/systemd/system/ddns-go.service

image
移除 -c 选项后,故障依旧

@jeessy2
Copy link
Owner

jeessy2 commented Feb 26, 2023

-c 需要指定全路径,都没提示你配置了,说明加载了。报错Geting current user failed! 是正常的,服务环境找不到用户HOME目录,不是以用户运行的

@jeessy2
Copy link
Owner

jeessy2 commented Feb 26, 2023

https://github.com/jeessy2/ddns-go/blob/master/main.go#L33
服务运行默认初始此段,实际已指定目录了的。感兴趣可看下

@WaterLemons2k
Copy link
Contributor

另外,由于 ddns-go 安装为 system service,system service 没有 $HOME 变量,所以报错 Geting current user failed!,但是 user service 有 $HOME 变量。

参考:

@jeessy2
Copy link
Owner

jeessy2 commented Feb 26, 2023

4.5.6不显示了。不过指定的相对路径是不行的,要绝对路径。

jeessy2 pushed a commit that referenced this issue Feb 28, 2023
* fix: add environment `HOME` to service and revert #576 and "fix: If getting user home with error, don't display the logs (#577)"

This should really fix #575.

* fix(main.go): add config file path to the service only if it is not equal to the default config file path

* chore(main.go): update the description of the service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants