Vely logo install examples
documentation about

14.2.0 released on Nov 29, 2022

FastCGI client



DESCRIPTION:


You can use cgi-fcgi command-line utility to communicate with your FastCGI application without using a web server. Use it to get responses from the command line. This is useful for shell scripting, debugging, testing etc.

If you have application <app name> running, for example 3 concurrent processes:

vf -w 3 <app name>

then you can send requests to it and receive replies:

export REQUEST_METHOD=GET
export SCRIPT_NAME="/<app name>"
export PATH_NAME="/<request name>"
export QUERY_STRING="par1=val1&par2=val2.."
cgi-fcgi -connect /var/lib/vv/<app name>/sock/sock  /<app name>

If you're running your application on TCP/IP instead of Unix socket (as above), for instance on TCP port 3000:

vf -w 3 -p 3000 <app name>

then you can send requests to it and receive replies:

cgi-fcgi -connect 127.0.0.1:3000  /


EXAMPLES:


The following example will create an application with 3 Vely request files, and test them as FastCGI application (both using Unix sockets and TCP) and as a command_line program. You can execute below bash commands one by one, or save them in a single file and run:

#
#Create hello_1.vely source file
#
echo '#include "vely.h"

void hello_1()
{
out-header default
@Hello World #1
}' > hello_1.vely

#
#Create hello_2.vely source file
#
echo '#include "vely.h"

void hello_2()
{
out-header default
@Hello World #2
}' > hello_2.vely

#
#Create Vely application named "hithere"
#
sudo vf -i -u $(whoami) hithere

#
#Make the application
#
vv -q

#
#Stop (any) running server processes
#Start 2 workers for your application running as FastCGI server via Unix sockets
#
vf -m quit hithere
vf -w 2 hithere

#
#Send request to execute hello_1() function.
#
export REQUEST_METHOD=GET
export SCRIPT_NAME="/hithere"
export PATH_INFO="/hello_1"
export VV_SILENT_HEADER=no
cgi-fcgi -connect /var/lib/vv/hithere/sock/sock  /hithere

#
#Restart your application as FastCGI server running on TCP port 3000
#Then send request to execute hello_2() function.
#
vf -m quit hithere
vf -p 3000 -w 2 hithere
export REQUEST_METHOD=GET
export SCRIPT_NAME="/hithere"
export PATH_INFO="/hello_2"
export VV_SILENT_HEADER=no
cgi-fcgi -connect 127.0.0.1:3000 /

#
#Run your application as command line program. Supress HTTP headers.
#
export REQUEST_METHOD=GET
export SCRIPT_NAME="/hithere"
export PATH_INFO="/hello_2"
export VV_SILENT_HEADER=no
/var/lib/vv/bld/hithere/hithere


SEE ALSO:


Running application ( application_setup   CGI   command_line   containerize_application   FastCGI   FastCGI_client   plain_C_FCGI  )  SEE ALL (documentation)



Copyright (c) 2022 DaSoftver LLC. Vely is a trademark of Dasoftver LLC. The software and information herein are provided "AS IS" and without any warranties or guarantees of any kind. Some icons copyright PaweĊ‚ Kuna licensed under MIT. Vely elephant logo copyright DaSoftver LLC. This web page is licensed under CC-BY-SA-4.0.