Exit nginx server block file - nginx-config

image
How do you exit the server block file?
I've used "vi /etc/nginx/sites-available/default", and I don't know how to save it and exit.

Related

simultaneously need to exit current perl script while opening the pdf file

I have a script to open the pdf file (Not in Adobe Acrobat application) instead Sumatra application (Pdf viewer).
system("start Sumatra C:/Users/test/Desktop/19June.pdf");
exit;
The problem is once we need to close the pdf file then only the script exited. But the requirement is the tool will be exit and not considered the opened pdf file.
Use exec instead of system. exec replaces the current process with the one given, while system will start a new process and wait for it to exit.

How to terminate a terminal session in a ps1 script

How can I terminate a terminal/PowerShell window from a .ps1 script? I would like it to work the way exit in command line works, but when I put that in a PowerShell script it only terminates the script.
Environment.Exit() will terminate the whole process:
# replace 0 with a non-0 error code if you want to indicate some sort of failure
[Environment]::Exit(0)

STDERR output in asterisk cli

How can i see the output to STDERR in asterisk CLI? I found that the stderr output is visible in the original asterisk terminal but cannot be seen in the cli which is obtained by asterisk -cvvvvvvvvvr. I want to see the error message of my perl agi script (warn "text") .
You can't see it.
Reason: stderror sended to linux stderror handler of asterisk process. When you connect to asterisk console, you have other proccess which have other stderror handler.
So if you want see errors, you need setup your asterisk startup script to store that errors in some file. Or edit default script /usr/sbin/safe_asterisk to suite your need.
Actualy if you read AGI specification you can see,that your script have send error messages to stdout,preferable using WARNING agi function. That can be archived by redirecting stderror to stdout in script or by writing special handler/wrapper.

Profiling a Perl CGI script that times-out

I have a Perl CGI application that sometimes times out, causing it to be killed by Apache and 504 Gateway Time-out error to be sent to browser. I am trying to profile this application using NYTProf, however I cannot read profile data:
$ nytprofhtml -f www/cgi-local/nytprof.out
Reading www/cgi-local/nytprof.out
Profile data incomplete, inflate error -5 ((null)) at end of input file, perhaps the process didn't exit cleanly or the file has been truncated (refer to TROUBLESHOOTING in the documentation)
I am using sigexit=1 NYTProf option. Here's minimal CGI script that reproduces problem:
#!/usr/bin/perl -d:NYTProf
sleep 1 while 1;
Setting sigexit=1 tells NYTProf to catch the following signals:
INT HUP PIPE BUS SEGV
However, when your CGI script times out, Apache sends SIGTERM. You need to catch SIGTERM:
sigexit=term
To catch SIGTERM in addition to the default signals, use:
sigexit=int,hup,pipe,bus,segv,term
CGI.pm has a debug mode, which you can use to run your program from the command line, and pass your CGI parameters as key/value pairs.
It has another feature that you can use to save your params to a file, and then read that file back in later.
What I've done is added the code to save the params to a file, and run my program, via a browser. This also facilitates my abilty to insure that the browser is sending the correct data.
Then I change the code to read the params from the file, and run it as often as I need until I have everything else debugged.
Once you've got the program running to your satisfaction from the command line, you can run it via nytprof to figure out what is taking all the time.

Returning handle to calling script perl

I have an executable which can run perl scripts using the following command at the prompt:
blah.exe Launch.pl
The way we have our tests setup is that we call the Launch.pl from Parent.pl like this "blah.exe Launch.pl" - script within script. However, when executing the command with backticks/system command the parent .pl script execution waits till I get the handle back by closing and exiting out of the application (blah.exe). At this point the code in parent.pl continues to execute.
How do I return the handle back to the parent .pl script after I get done running the code that is contained in the Launch.pl
So, parent.pl calls "blah.exe Launch.pl"; but after running the code inside Launch.pl inside the application (blah.exe) it just sits there waiting to be exited out of so that the code in parent.pl can continue running. I need to keep the application (blah.exe) open till I am done running a bunch of scripts one after another.
Run blah.exe in the background. When you are done with the Parent.pl, terminate the application with kill.