Vely logo Empower C
install     tutorials     examples     documentation     license     about

11.0.11 released on Jul 25, 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 QUERY_STRING="req=<request name>..."
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:
export REQUEST_METHOD=GET
export SCRIPT_NAME="/<app name>"
export QUERY_STRING="req=<request name>..."
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.v source file
#
echo '#include "vely.h"

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

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

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

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

#
#Make the application
#
vv -q hithere

#
#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 QUERY_STRING="req=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 QUERY_STRING="req=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 QUERY_STRING="req=hello_1"
export VV_SILENT_HEADER=yes
/var/lib/vv/bld/hithere/hithere


SEE ALSO:


Running application ( plain_C_FCGI   containerize_application   command_line   application_setup   CGI   FastCGI   FastCGI_client  )  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. This web page is licensed under CC-BY-SA-4.0.