Title: Using DVM in an XCF File for a Web Service Post by: Sean H. on January 23, 2023, 02:28:08 pm We use DVMs for quite a lot of our GAS App Configurations in order to dynamically change environment variables on launch
/opt/example.sh Code
/opt/fourjs/gas/appdata/app/example.xcf Code
This way we can pass arguments via the GDC to apply settings before launch http://server/gas/wa/r/example?Arg=v001&Arg=jdk17 I was wondering if it possible to do the same thing with Web Services because I've only been able to get them to work with configurations like the below /opt/fourjs/gas/appdata/services/exampleweb.xcf Code
How can I use a script for the DVM in the same way as can be done with applications? Title: Re: Using DVM in an XCF File for a Web Service Post by: Reuben B. on January 23, 2023, 10:22:36 pm What version? There was an issue many years and versions ago but you are hopefully on a more recent version https://4js.com/support/issue/?id=GAS-831
Also note, DVM does appear in the hierarchy http://4js.com/online_documentation/fjs-gas-manual-html/#gas-topics/c_gas_extappref_ws_element_listing.html just like it does for Web Apps http://4js.com/online_documentation/fjs-gas-manual-html/#gas-topics/c_gas_extappref_element_listing.html Otherwise what is appearing the logs may give a clue Reuben Title: Re: Using DVM in an XCF File for a Web Service Post by: Sean H. on January 24, 2023, 08:37:21 am Hello Reuben, hope you're keeping well.
It's currently on 3.10 When using these settings /opt/fourjs/gas/appdata/services/exampleweb.xcf Code
I'm getting these errors Web Response Code
/opt/fourjs/gas/appdata/log/fastcgidispatch.log Code
/opt/fourjs/gas/appdata/log/gwsproxy-exampleweb.log Code
/opt/fourjs/gas/appdata/log/vm-exampleweb-0.log Code
Sorry for dumping out a whole bunch of logs, I'm just not 100% sure which bits are the most relevant Title: Re: Using DVM in an XCF File for a Web Service Post by: Sean H. on January 24, 2023, 08:46:53 am Sometimes I will get only this error
/opt/fourjs/gas/appdata/log/fastcgidispatch.log Code
Title: Re: Using DVM in an XCF File for a Web Service Post by: Reuben B. on January 24, 2023, 09:05:50 am Hello Reuben, hope you're keeping well. It's currently on 3.10 When using these settings /opt/fourjs/gas/appdata/services/exampleweb.xcf Code
I'm getting these errors Web Response Code
/opt/fourjs/gas/appdata/log/fastcgidispatch.log Code
/opt/fourjs/gas/appdata/log/gwsproxy-exampleweb.log Code
/opt/fourjs/gas/appdata/log/vm-exampleweb-0.log Code
Sorry for dumping out a whole bunch of logs, I'm just not 100% sure which bits are the most relevant Try removing this line from your .xcf <ENVIRONMENT_VARIABLE Id="FGLAPPSERVER">6401</ENVIRONMENT_VARIABLE> Note the last line here http://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_EnvVariables_FGLAPPSERVER.html Reuben Title: Re: Using DVM in an XCF File for a Web Service Post by: Sean H. on January 24, 2023, 09:33:35 am Hello Reuben,
Removing that environment variable fixed it, that's a relief, I don't know how I missed that. Thank you so much for your assistance Title: Re: Using DVM in an XCF File for a Web Service Post by: Reuben B. on January 25, 2023, 03:50:17 am Sometimes I will get only this error /opt/fourjs/gas/appdata/log/fastcgidispatch.log Code
FYI For education purposes, if you see the "Failed to retrieve service configuration" error message it indicates that the .xcf file for the Web Service (in this case exampleweb.xcf) cannot be found, or an APPLICATION entry in the main .xcf (in this case APPLICATION ... Id="exampleweb") in the main .xcf is not there either. One of the first things that occurs when the request /ws/r/exampleweb is received is that this is resolved to find the details and configuration for the intended Web Service if it is not running, and this error message is saying it cannot find that information. Odd that you get it "sometimes", a potential cause might be placing exampleweb.xcf file in /appdata/app instead of appdata/services, or mistyping the filename when you save it. Reuben Title: Re: Using DVM in an XCF File for a Web Service Post by: Reuben B. on January 25, 2023, 04:03:19 am Hello Reuben, Removing that environment variable fixed it, that's a relief, I don't know how I missed that. Thank you so much for your assistance Again for education purposes, think of FGLAPPSERVER as the port that the fglrun process is listening out on. When you are testing and you start fglrun manually, then you have to set that variable beforehand so that fglrun knows what port to listen on. When you introduce a Web Server, it is the proxy process that is starting fglrun and finding and setting an unused port to communicate on, it is the proxy that is setting FGLAPPSERVER and establishing that communication channel between the proxy process and the fglrun process. (see various architecture diagrams http://4js.com/online_documentation/fjs-gas-manual-html/#gas-topics/c_gas_architecture_001.html) The clue in the logs is that it is starting the fglrun process at 7:21:23 but at 7:21:33 no communication has been received back (10 seconds later being the DVM_AVAILABLE timeout). Either the fglrun process has not started, or it has started and crashed, or it has started and is not able to establish communication. The lack of an error message in the VM log is telling you the fglrun process has started and hasn't crashed. So then question is why hasn't it established communication, perhaps it is on the wrong port ... Title: Re: Using DVM in an XCF File for a Web Service Post by: Sean H. on January 25, 2023, 08:23:59 am Thanks so much Reuben, that makes a lot of sense regarding the FGLAPPSERVER Port.
The only thing that seems to fail though is when I include the AllowUrlParameters="TRUE" to the EXECUTION in the XCF. It gives me the error /opt/fourjs/gas/appdata/log/fastcgidispatch.log Code
I was using this to provide arguments to the DVM GDC URL Code
/opt/exampleweb.sh Code
Is there another way to do this with a Web Service? Title: Re: Using DVM in an XCF File for a Web Service Post by: Reuben B. on January 25, 2023, 10:49:07 pm Drilling down from the Configuration File Hierarchy documentation pages for applications (http://4js.com/online_documentation/fjs-gas-manual-html/#gas-topics/c_gas_extappref_element_listing.html) and web services (http://4js.com/online_documentation/fjs-gas-manual-html/#gas-topics/c_gas_extappref_ws_element_listing.html) is a great way to check syntax of .xcf files.
You can see that the application EXECUTION node http://4js.com/online_documentation/fjs-gas-manual-html/#gas-topics/c_gas_asref_APP_LIST_APP_EXECUTION.html does have an AllowUrlParameters parameter whilst the Web Service EXECUTION node http://4js.com/online_documentation/fjs-gas-manual-html/#gas-topics/c_gas_asref_SERVICE_LIST_APP_EXECUTION.html does not have an AllowUrlParameter attribute. There is a very good reason for that. When you type in a URL to start a web application, that starts a Genero program each and every time. When you make a Web Service call it does not start a new Genero program each and every time. , a single Genero program can and will be kept running to answer many web service requests. This allows overhead such as connecting to a database to be done once when the program starts and not on every web service call. If the program arguments you want to use are static, that is they don't change on each web service call then you use the PARAMETERS element http://4js.com/online_documentation/fjs-gas-manual-html/#gas-topics/c_gas_asref_PARAMETERS.html inside the EXECUTION element in your .xcf A good way to think of those child elements of the EXECUTION element is that they get turned into the following ... export ENVIRONMENT cd PATH DVM MODULE PARAMETERS So having Code
within your service xcf gets turned into Code
If however you are attempting to use the URL values as dynamic arguments for the Web Service call, then make sure you are using 3.20 or above and the high-level RESTful web service concepts that were introduced there. There are many ways to pass arguments to the Web Service call that then get passed through to the underlying 4gl function. I recently put up on Github an example that illustrates the many different ways https://github.com/FourjsGenero/ex_ws_input_methods For example, you would use WSQuery to pass v001, jdk17 like so ... http://server/gas/ws/r/example?p1=v001&p2=jdk17 ... and have your web service function called with v001 and jdk17 passed as parameters to that function. Hope that helps Reuben Title: Re: Using DVM in an XCF File for a Web Service Post by: Sean H. on January 26, 2023, 08:42:47 am I'm looking more for passing parameters to the DVM script itself instead of the Application to dynamically change the Environment Variables being set up by the DVM script before the application is launched but all of this information is enough for me to get started with what I need.
Thank you so much Reuben for all of the assistance! I'm very keen to work with the Web Services they seem very powerful |