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

yaws configured in systemd isn't recognized by yaws on the command line #404

Open
slavamas opened this issue Sep 3, 2020 · 3 comments
Open

Comments

@slavamas
Copy link

slavamas commented Sep 3, 2020

installed yaws on Debian 10 (buster)
Linux deby 4.19.0-10-amd64 #1 SMP Debian 4.19.132-1 (2020-07-24) x86_64 GNU/Linux
root@deby:/etc/yaws# yaws --version
Yaws 2.0.6

==============
systemctl status yaws.service
● yaws.service - High performance HTTP 1.1 webserver written in Erlang
Loaded: loaded (/lib/systemd/system/yaws.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2020-09-02 22:56:50 PDT; 12min ago
Process: 26434 ExecStart=/usr/bin/yaws --conf $YAWS_CONF --id $YAWS_ID --daemon $DAEMON_OPTS (code=exited, status=0/SUCCESS)
Process: 26448 ExecStartPost=/usr/bin/yaws --id $YAWS_ID --wait-started=10 (code=exited, status=0/SUCCESS)
Tasks: 20 (limit: 4915)
Memory: 26.6M
CGroup: /system.slice/yaws.service
├─26449 /usr/lib/erlang/erts-10.2.4/bin/beam.smp -K true -- -root /usr/lib/erlang -progname erl -- -home /var/cache/yaws -- -noshell -noinput -heart -pa /usr/lib/yaws/ebin -run yaws -
├─26456 erl_child_setup 1024
└─26479 heart -pid 26449

Sep 02 22:56:48 deby systemd[1]: Starting High performance HTTP 1.1 webserver written in Erlang...
Sep 02 22:56:50 deby systemd[1]: Started High performance HTTP 1.1 webserver written in Erlang.

yaws --ls
Id Status Owner

default stopped root
deby_yaws stopped root
deby stopped root

systemctl stop yaws
root@deby:/etc/yaws# yaws --id deby -D --heart
root@deby:/etc/yaws# yaws --id deby --status
IP Port Connections Sessions Requests
192.168.0.20 8080 0 1 0
0.0.0.0 8443 0 1 0

Uptime: 0 Days, 0 Hours, 0 Minutes

@vinoski
Copy link
Collaborator

vinoski commented Sep 3, 2020

Make sure HOME for command-line Yaws matches that of the Yaws running under systemd. Looks like HOME for systemd is set to /var/cache/yaws, so from the command line you could try running

root@deby:/etc/yaws# HOME=/var/cache/yaws yaws --id deby --status

@slavamas
Copy link
Author

slavamas commented Sep 4, 2020

That could obviously work. ( I might be mistaken, but I don't think I have seen any explanations of this in the manual).
But, systemd run by root user. Wouldn't be easier and better to copy CTL file from /var/cache/yaws/.yaws/ to /root/.yaws/yaws/ so, yaws would be able to read it as it does for any other process running by user root?
or maybe create a symlink from /var/cache/.yaws/yaws to /root/.yaws/yaws?

@vinoski
Copy link
Collaborator

vinoski commented Sep 4, 2020

HOME is mentioned in the yaws.conf.5 man page.

The -home /var/cache/yaws argument shown in the beam.smp command line is coming from the HOME environment variable in effect at the time systemd is starting Yaws. If that's not what you want, you might try a different HOME setting under systemd. Yaws has no idea that what's running in systemd is intended to be the same as what you're running from the command line, so it would have no way of copying or linking the two. Copying would allow the two areas to get out of sync, so that's not a good approach. The link avoids that, but it's still really just a workaround for the real problem.

Also, general advice is to avoid running as the root user; you should instead make a user account for the web server and run it under that account. Doing that would also fix this HOME issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants