-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
notify: implement windows service status and error notifications #7389
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
notify: implement windows service status and error notifications #7389
Conversation
|
Thanks!
Did you test it on Windows to make sure it does what you expect? Or did you just compile it? |
I just compile it , if the other previous functions already works, because are on main branch , these work too because are the same code as well , these are basic operations , anyways today i want to test on a windows machine because using CI from github actions |
00b7a41 to
ff9afad
Compare
240adbc to
9e18c22
Compare
89089cc to
3515ae9
Compare
|
I already run a lot of tests this morning on github Actions , that's why have the force pushes , i tested , update the code and delete the commits with the test.yml used for testing |
FreyreCorona
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already test this code and it work as expected , but , in anywhere is called the Status function , it's because are not implemented or other some reason ?
|
I don't understand the question. Can you clarify what you mean? |
|
FYI @WingLim since you originally contributed the notify stuff, if you'd like to take a look |
I Search on all LSP references for the function Status , and did not found any call 0 incoming calls |
|
Ah, I think it was just to cover the systemd APIs on linux (i.e. it has a |
|
Hi @WingLim , all the revision changes are applied |
|
@mohammed90 , i think it's correct now , i tried to avoid create a new error object for pass arguments as zap.Error() , instead i used a zap.String() for simplicity , i be used caddy.Log().Warn() instead o Error() ?? |
mholt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for iterating on this! Looks good to me, though I don't understand the Windows APIs personally.
|
@mohammed90 , The linters are failing because import caddy.Log on notify make a circular dependency with import notify on caddy module , thats why the first time i use log directly , after make a change for fix that , i wanna ask. There is another way to do this ? like importing zap directly and calling default logger on it ? or simply use log library ? Ignore them like @WingLim says? |
|
Can The other option is to revert to using just std lib Actually yeah maybe just using std lib log is better than moving the whole package files. |
|
I understand , just go backward on the commit for these change , i wait for responses for other members or just rollback the commit ? |
|
Yes, since we're blocked with import cycle, we can revert to stdlib log. |
0b95707 to
07f2401
Compare
|
Could we move notify into |
|
🤷♂️ if you import caddy module on notify and notify on module caddy you always get the error , you wanna delete the notify module ? |
|
Nope, I don't think that will work. Still an import cycle. |
|
Why will use Zap library on the first place ? it's not better an simple use log/slog of the std library ???? |
|
We use zap because Caddy v2 was designed before slog existed. We have a compatibility layer for slog for plugins to use though. But anyway, I think it's fine that we just plainly log in this case because it should never actually happen unless we had bad code which uses an unsupported status. |
I think the same , if you pass a unsupported status , the function will be a NO-OP , just log for give it some debug information |
This change refines the internal logic used by the Windows Service module to report state updates to the Service Control Manager (SCM).
A new Status(name string) function was added to map human-readable state names (“running”, “stopped”, etc.) into the corresponding svc.State values. This centralizes state translation and avoids duplicated logic.
The Error function was also updated to send a StopPending status through the global status channel before returning, ensuring the SCM is consistently notified when the service fails.
Overall, the goal is to improve communication with the SCM and avoid inconsistent state transitions during service shutdown or failure.
Motivation:
The current implementation does not exist, and te big TODO reaveal this. Consolidating state mapping and making error reporting explicit improves maintainability and reduces the risk of state desynchronization.
How it was tested:
– Cross-compilation for Windows (GOOS=windows) to ensure the module builds correctly.
– Manually tested on CI (github Actions) to ensure the functions are work as expected (now)
The modifications only affect internal state reporting logic on Windows systems.
The code was generated by me(human) and the text of this PR was generated by ChatGPT