Use newlisp to manage nginx in Windows

Source: Internet
Author: User

I wrote an nginx. LSP file, which can be used to manage nginx processes by passing parameters.

Usage

1. Download the Windows version from the nginx siteProgramAfter pressurization, copy the newlisp. LSP file to this directory.

2. Ensure that the system 32 directory of Windows contains the newlisp.exe program.

3. Run the program. Currently, five parameters are supported.

 

 
Newlisp nginx. lsp start | stop | monitor | reload | View

 

For example, we use view to observe the process:

 

C: \ newlisp nginx. LSP viewimage name PID session name session # mem usage ============================== ================================ zookeeper has been installed without authorization before using nginx.exe 8048 console 1 6,716 knginx.exe 4512 console 1 6,988 knginx.exe 1684 console 1 6,836 knginx.exe 4652 console 1 7,132 knginx.exe 6512 console 1 6,816 knginx.exe 6868 console 1 7,152 K

You can use the stop parameter to disable all nginx processes.

 

ImplementationCodeAs follows:

 

; Parse argument as one of the following; Start | stop | reload | monitor | view (define (start) (process "start. bat ") (define (kill-process E) (if (RegEx" ^nginx.exe "E) (begin (set 'pid (RegEx "^nginx.exe [] + ([0123456789] +)" E) 3 )) (Exec (APPEND "taskkill/PID" PID "/F") (define (handle-Element E) (if (RegEx "^nginx.exe" E) (set 'H true) (define (check-nginx-process) (set 'cmd "tasklist/FI \" imagename EQ nginx.exe \"") (set 'result (Exec cmd) (set 'H nil) (dolist (STR result) (handle-element Str) (define (kill-nginx-processes) (set 'cmd "tasklist/FI \" imagename EQ nginx.exe \ "") (set 'result (Exec cmd) (set 'H nil) (dolist (STR result) (kill-process Str) (define (View) (set 'cmd "tasklist/FI \" imagename EQ nginx.exe \ "") (set 'result (Exec cmd )) (dolist (STR result) (println Str) (define (STOP) (set 'cmd "tasklist/FI \" imagename EQ nginx.exe \"") (set 'result (Exec cmd) (check-nginx-process) (if H (begin (println "stoping nginx now... ") (EXEC" nginx-S Stop ") (check-nginx-process) (if H (begin (println" Kill nginx processes... ") (kill-nginx-processes) (println" do nothing because nginx is stopped ") (define (reload) (EXEC" nginx-s reload ")) (define (MONITOR) (while true (begin (sleep 10000) (println "Check nginx process at 10 seconds") (check-nginx-process) (Unless H (begin (println "nginx is stopped, start it now... ") (start) (println" nginx process is alive ") (define (main-fun) (set 'Action (main-ARGs) 2 )) (Unless action (begin (println "Please pass one of the arguments: Start | stop | reload | monitor | View") (exit) (if (= "start" Action) (start) (if (= "stop" action) (STOP) (if (= "reload" action) (reload) (if (= "Monitor" Action) (Monitor) (if (= "View" action) (View) (main-fun) (Exit)

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.