Open studersi opened 6 years ago
Thanks. Looks like fun.
I have a few issues with this PR, though. Please fix these.
The error message for missing inotify package is rather ugly. There should be a dependency check with a nice error message and the help as well as the inline documentation should explain the dependency.
The Ctrl-C combination is only explained from the 2nd call
If you make an error in the config and save it, the server is stopped and can no longer be started. use the binary's config test to check prior to stopping the running server
The script ought to be more transparent and verbose with what it does. I have something in mind like the following.
...
14:23:22 Setting up inotify watches
14:23:22 Entering watch mode
14:24:15 File has been changed. Checking config ... ok. Restarting ...
14:25:15 Stopping active apache process ... ok
14:25:16 Launching apache config file '/apache/conf/httpd.conf_pod_2018-04-23_14:38' ... ok
14:25:16 Edit and save file to restart apache, press [Ctrl+C] to exit.
14:25:22 File has been changed. Checking config ... FAIL.
14:25:22 Error message: Invalid command 'SrcRule', perhaps misspelled or defined by a module not included in the server configuration
...
You can also make this optional via a -v
switch.
Good suggestions.
The current version is more of a PoC than anything else but now that it appears to work, I'll look into streamlining it as you suggested.
I was even thinking of adding a manual mode (-m
switch) in case it's run on a system where the user doesn't have permissions to install the inotify package.
Yep, thought so.
I like the -m switch idea to revert back to the former behaviour.
Great, I'll start working on it some time this week.
[x] It is not possible to manually restart the server by pressing Enter
anymore. (See ca1cf17)
[x] Exiting with Ctrl+c
does not make a clean shutdown like the entering q
did before. (See 0b184b9)
[x] The error message for missing inotify package is rather ugly. There should be a dependency check with a nice error message and the help as well as the inline documentation should explain the dependency. (See 0c33564)
[x] The Ctrl-C combination is only explained from the 2nd call. (See 9d09507)
[x] If you make an error in the config and save it, the server is stopped and can no longer be started.
use the binary's config test to check prior to stopping the running server. (See b0bf81f)
[x] The script ought to be more transparent and verbose with what it does. I have something in mind like the following. (See ad6bb86)
(This checklist will be updated according to progress)
This version of apachex
should be fairly streamlined now.
The new features include:
-m
flag (apachex -m
). In manual mode, no inotify tools are required and apache is restarted by pressing enter.Ctrl+c
. The program traps the signal and executes the shutdown code that was previously used.httpd -t
).-v
flags.
apachex
: Minimal output necessary to understand what is happening. It is very similar as before.apachex -v
: Additional output that makes it easier to debug what the program is doing.apachex -v -v
: In addition to the previous verbosity level, timestamps are shown for each output. Note that the way command line arguments are parsed apachex -vv
does not work.This branch is now ready for merging.
I refactored the argument parsing a bit. It is now possible to use -vv
instead of -v -v
but it is still not possible to do -vm
, they have to be passed as -v -m
.
Also, I added the flag -c
to specify an apache config file to be used (i.e. apachex -c conf/httpd.conf
).
Can you try out this version of
apachex
to see if it works for you?Requirements
inotify-tools
package for it to workIssues
Enter
anymoreCtrl+C
does not make a clean shutdown like the enteringq
did before