unit
unit copied to clipboard
Documentation: Add Startup / Shutdown section for systems without systemd (WSL)
I understand there is no windows native build #604
Would it be possible to update unit to make it compatible with WSL2?
I had problems getting Unit working using on WSL2, as systemd isn't installed. I did manage to get it working and documented it:
I think there are two possible options:
- Update unit to be compatible with WSL2, without systemd
- Update the official docs to explain how to install unit on WSL2, as per my blog
I have no idea what would be involved with option 1, this would be the preferred method, the user would install unit following the unit ubuntu documentation and it "just works". Option 2 could be a stop-gap unit until option 1 is implemented.
We have a couple of patches to make unitd
work without systemd (or any other init support).
https://github.com/nginx/unit/pull/747 https://github.com/nginx/unit/pull/743
The idea is that after those two patches are applied, one should be able to just ./configure && make && sudo make install && sudo unitd
from the source code and it should work out-of-the-box.
Just to be sure that you have no other issue, what are the exact problems you had?
Just to be sure that you have no other issue, what are the exact problems you had?
I expected to install unit and it would automatically run, or I could follow the documentation to start it systemctl restart unit
, however, this doesn't work without systemd.
The workaround is to start to manually using: sudo unitd --control unix:/var/run/control.unit.sock
which is undocumented.
Once unit was started it works 🎉, I could follow the remaining documentation and get the hello world example running in my browser. 👍
The issue with option 1 is that systemd simply doesn't work in WSL2. We should document the way to run it correctly under WSL2 in our docs, I agree.
Could you please try sudo unitd
without the flag, and see if it works?
Good result 🎉
In wsl:
sudo unitd
[sudo] password for michael:
2022/08/31 13:20:00 [info] 57#57 unit 1.27.0 started
sudo curl --unix-socket /var/run/control.unit.sock http://localhost/config/
{
"listeners": {
"127.0.0.1:8000": {
"pass": "applications/helloworld"
}
},
"applications": {
"helloworld": {
"type": "php",
"root": "/www/helloworld/"
}
}
}
Opened my windows browser to localhost:8000 and was treated to Hello world 😀
Great. I suspect this works with the Ubuntu package, but won't work with other packages, due to a different default path for the control socket. But good that it works for you!
@Pen-y-Fan thanks again for sharing this and yes for us the way to start Unit without using systemd
is our daily business but for others it is quite complicated to figure it out.
I will rename this issue and tag it as a lack of documentation on our website. We will add this section to https://unit.nginx.org/installation/#startup-and-shutdown
so it become more clear what to do on systems without systemd.