table of contents
| GOLF(2gg) | Development | GOLF(2gg) |
NAME¶
gg - (golf-compiler-and-utility)
PURPOSE¶
Golf general purpose utility: build, test, run, miscellaneous (pronounced "gigi").
SYNTAX¶
gg <options>
DESCRIPTION¶
COMMAND-LINE OPTIONS
The following options can be used when building an application:
Each <database vendor>:<db config file> is separated by a space. You can list any number of databases for use in your application. A file in current directory with name <db config file> must exist and contain the connection parameters for database access, and is copied to Golf's database configuration directory (see directories). See database-config-file for more details on the content of this file.
/<app name>
Note that when any gg compilation options change, the application is rebuilt (i.e. the change has the effect of "--clean").
[ --app="application path" ]
[ --service [ --remote="server:port" ] [ --socket="socket path" ] ]
[ --method="<request method>" ]
[ --content="<input file>" --content-type="<content type>" ]
[ --silent-header ]
[ --arg="<arguments>" ]
[ --exec ] Run a command-line program, or make a service request, or display bash code to do the same for use in scripts.
If you are not in application's source code directory, then you must specify "--app" option to supply the application path (typically "/<application name>", see request). You can use "--req" option to specify the request name and optional URL parameters (see request), for example it may be:
gg -r --req="/encrypt" --exec
to execute request "encrypt", or
gg -r --req="/encrypt/data=somedata?method=aes256" --exec
where "/encrypt" is the request name, and "/data=somedata?method=aes256" represents the URL parameters.
Use --method to specify the HTTP request method, for instance:
gg -r --req="/encrypt/data=somedata?method=aes256" --method=POST --exec
If not specified, the default method is "GET".
If "--service" is not used, then command-line program will execute and you can specify program arguments with "--arg" option, in which case "<arguments>" is a string (double or single quoted) that contains any number of program arguments. To specify arguments for a service see "-a" option in mgrg.
If "--service" is used, then application server will be contacted to execute a service; in this case if "--remote" is not specified, a local Unix socket is used to contact the server; otherwise "server:port" specified in "--remote" is the IP/name and port of the server to call, separated by a colon (":"). In case of a local Unix socket, the socket path is by default "/var/lib/gg/<app name>/sock/sock", where "/<app name>" is given by the last path segment in "--app" option, or if not specified it is derived from the name of a Golf application built in the current directory; otherwise the socket path is given by "--socket" option.
By default, the output in any case will have the HTTP headers. If you don't want those to appear, use "--silent-header" option.
If "--content" is used, then file <input file> is either piped to the standard input of a command-line program (if "--service" is not used), or sent as a content to the application server (if "--service" is used). You can also specify content type with "--content-type". For example:
gg -r -app="/my_app" --req="/some_request?par1=val1&par2=20&par3=4" --method=PATCH --content=something.json --content-type=application/json --exec
Examples of using "-r" option to execute command-line program or to call a service:
#Execute current application as a command-line program, request "json" gg -r --req="/json" --exec #Execute application "app_name", service "json" by calling the application server running with a Unix socket gg -r --req="/json" --app="/app_name" --service --exec #Execute application "app_name", service "json" by calling the application server running with a Unix socket (specified explicitly) #Request has input parameter "act" with value "perf" gg -r --req="/json?act=perf" --app="/app_name" --service --socket="/sock_path/sock" --exec #Execute application "app_name", service "json" by calling the application server running with a TCP socket on port 2301 #Request has input parameter "act" with value "perf" gg -r --req="/json/act=perf" --app="/app_name" --service --remote="192.168.0.21:2301" --exec
- Performance
"gg -r" can be used both for testing and in production, however for maximum performance, skip "--exec" option to display direct bash code that you can copy and paste to use in production. This direct code is about 300% faster than using "gg -r"; keep this in mind if performance of using "gg -r" is important. When "--exec" is not used, the output may look like this:
export CONTENT_TYPE= export CONTENT_LENGTH= unset GG_SILENT_HEADER export GG_SILENT_HEADER export REQUEST_METHOD=GET export SCRIPT_NAME="/enc" export PATH_INFO="/encrypt/data/somedata" export QUERY_STRING="method=aes256" /var/lib/gg/bld/enc/enc
If you copy the above and paste into bash shell, it will execute the command line program which handles the request specified (which gg would do when "--exec" is specified, but not as fast). Note that SCRIPT_NAME will be set to whatever application path you use (i.e. the default or if set with "--path" option when making the application; or with "--app" option here), see request.
If you need to have run-time parameter(s) to "gg -r", escape them when displaying the direct bash code and run with "eval", for instance:
COMM=$(gg -r --req="/func_test/update-data/key=\$i/value=d_\$i" --service --remote="127.0.0.1:2301")
...
for i in {1..1000}; do
...
RES=$(eval "$COMM")
...
echo "Result is $RES"
done
In this example, the code with "$i" variable is created, and then evaluated in a bash loop of 1000 iterations, with each execution of your service using dynamic run-time input parameter "$i", but without executing "gg -r" 1000 times.
EXAMPLES
gg -q --db="mariadb:mdb postgres:pdb sqlite:sdb" --debug --trace
gg -q --db="mariadb:db" --lflag "-Wl,-z,defs" --cflag "-DXYZ123" --maxupload 18000000
gg -q
SEE ALSO¶
Golf compiler and utility
gg See all documentation
| $VERSION | $DATE |