Hello
I do a lot of things with Active4D, which will not creating "normal"
html-Pages.
For this I have one 4D-Process, and a Table [Task].
In the Task-Records there I say for example: Call with a period of
600 Second A4D Execute with a file-path, and a pseudo-request-String.
600, /service/parseWeatherdata.a4d, maxData=12&lang=de
For debugging, I call this Scripts via web-browser.
Also I have a view Apple-Script request, which are making normal http-
Request , ore check if the Webserver is still working ok, to the 4d-
Webserver periodic.
Applescript with http-Request
property checkInterval : 600 -- Sekunden
property checkURL : "service.myserver.ch/admin/
saveRecordToTextFile.a4d?reqMode=applescript"
property waitonStartup : 1 -- Sekunden
property waitonQuit : 15 -- Sekunden
property waitonRequest : 300 -- Sekunden
--
property status : 1
property cr : "
" -- carriage return
on run
my write_error_log((cr & "--------------" & cr & the (current date)
as string) & cr & "RecordToTextFile neu gestartet." & cr &
"--------------")
checker(checkURL)
end run
on quit
my write_error_log((cr & "--------------" & cr & the (current date)
as string) & cr & "RecordToTextFile wird beendet." & cr &
"--------------")
continue quit
end quit
on idle
checker(checkURL)
return checkInterval
end idle
on checker(testPfad)
try
set siteurl to testPfad
with timeout of waitonRequest seconds
set pagesHTML to do shell script "curl " & siteurl
end timeout
if status = 1 then
my write_error_log(("RecordToTextFile OK. " & (current date) as
string) & pagesHTML)
set status to 0
end if
on error the error_message number the error_number
beep
set the error_text to the error_message
my write_error_log((cr & "--------------" & cr & the (current date)
as string) & cr & "Keine Verbindung zum Webserver." & error_text & cr
& "--------------")
set status to 1
end try
end checker
on write_error_log(this_error)
set the error_log to "apps:internet:server:RecordToTextFile.log"
try
open for access file the error_log with write permission
write (this_error & return) to file the error_log starting at
eof
close access file the error_log
on error
try
close access file the error_log
end try
end try
end write_error_log
-------------------
Apple-Script which is checks if the Server is still OK. If not restart
4D.
-------------------
property checkInterval : 30 -- Sekunden
property checkURL : "127.0.0.1:80/servercheck.html"
property waitonStartup : 30 -- Sekunden
property waitonQuit : 15 -- Sekunden
property waitonRequest : 10 -- Sekunden
--
property status : 1
property cr : "
" -- carriage return
on run
my write_error_log((cr & "--------------" & cr & the (current date)
as string) & cr & "ServerChecker neu gestartet." & cr &
"--------------")
end run
on quit
my write_error_log((cr & "--------------" & cr & the (current date)
as string) & cr & "ServerChecker wird beendet." & cr & "--------------")
continue quit
end quit
on idle
checker(checkURL)
return checkInterval
end idle
on checker(testPfad)
try
set siteurl to testPfad
with timeout of waitonRequest seconds
set pagesHTML to do shell script "curl " & siteurl
end timeout
if status = 1 then
my write_error_log("Verbindung zum Webserver OK. " & (current date)
as string)
set status to 0
end if
on error the error_message number the error_number
beep
set the error_text to the error_message
my write_error_log((cr & "--------------" & cr & the (current date)
as string) & cr & "Keine Verbindung zum Webserver." & error_text & cr
& "--------------")
my write_error_log("Versuche 4D zu schliessen")
tell application "4th Dimension"
quit
end tell
my write_error_log("Schliesse 4D")
delay waitonQuit
tell application "Finder"
my write_error_log("Oeffne 4D mit myTool.4DC")
open document file "myTool.4DC" of folder "server" of folder
"internet" of disk "apps"
delay waitonStartup
end tell
set status to 1
end try
end checker
on write_error_log(this_error)
set the error_log to "apps:internet:server:ServerChecker.log"
try
open for access file the error_log with write permission
write (this_error & return) to file the error_log starting at
eof
close access file the error_log
on error
try
close access file the error_log
end try
end try
end write_error_log
Regards, Oliver
Am 13.08.2008 um 17:28 schrieb Steve Alex:
There is a line in the Active4D reference manual that I'm not sure
what is the correct method of implementation.
Uses for Direct Execution
Direct execution is useful in cases where you are not responding to
an HTTP request. In
fact, you could easily use Active4D as a general-purpose scripting
engine by executing
files or blocks of text that are nothing but Active4D code. You need
only enclose the
scripts in the <% %> tags.
We've tried this over the years with mixed results. Now that we're
upgrading I need to ask a couple questions.
We are currently and probably will continue to run Active4D on a
client. There are some things I created in Active4D that it sure
would be nice if we could call them from the 4D (GUI or process).
While this worked on our development server (probably because I had
an expired license on it) it did not work on the real server since
Active4D is not running on the server.
For instance, we created a cron process on the 4D server and tried
to execute some Active4D code stored in a record. That crashed the
4D server - so we put that off to the side and said we'd get back to
it sometime. I think we figured out the licensing problem and was
going to use Execute on Client, but never got around to it.
I guess my questions are:
What is the best way to implement Active4D as a general-purpose
scripting engine (in client based web server environment)?
Should I buy two deployment licenses, one for the client web site
and one for the server?
Has anyone tried to execute Active4D text/file on a client from the
server?
I guess the option of two licenses would allow us to have a fallback
solution if the client died. Also would allow development of a
limited access site that I'm not sure what I'd do with - but then
something will come to mind sooner or later (long running reports,
conversion routines that are one heck of a lot easier to do in
Active4D, etc.) Of course that would require another 4D Web Server
license. Which brings up another question. Will Active4D work on a
box that does not have a web server running on it?
Steve Alex
AIDT
_______________________________________________
Active4D-dev mailing list
[email protected]
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/
_______________________________________________
Active4D-dev mailing list
[email protected]
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/