Livecode CGIs co-existing with old-school Rev 2.x CGIs

Are you using LiveCode to create server scripts or CGIs?

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
Stryder
Posts: 27
Joined: Fri Jul 21, 2006 12:05 pm
Location: Winnipeg, Canada

Livecode CGIs co-existing with old-school Rev 2.x CGIs

Post by Stryder » Tue Jul 15, 2014 2:25 pm

I have a dedicated Linux server running old-school Revolution 2.x with text-based CGIs. It's a very fast server, and that's one of my problems.

I have found a flaw with the old Rev in that as my servers have evolved over the past 10 years and gotten faster, Rev causes a problem. The problem is that if too much information is being returned by Rev to the browser, it just stops and cuts it off. I've had to carefully craft pages to not include too much HTML code and any returned results are truncated and shown on another page, but I still run into issues sometimes. My solution has been to cease upgrading my server for single-core performance and instead focus on heat efficiency, disk throughput, and multi-core so that more instances can be run. I currently have a quad-core Xeon running that works very well, but I thought I would start trying out LiveCode Server on this setup.

LiveCode seems to execute CGIs a little differently than Rev did. Rev code started like this:

Code: Select all

#!revolution

on startup
    (code here)
end startup
You placed the revolution stand-alone in the cgi-bin and referenced it as an AddHandler in Apache to execute CGIs.

Livecode works a bit differently, in that you preface your code with:

Code: Select all

<lc?
   (code here)
?>
I've downloaded and setup the community-edition server on my Linux box. However, I don't want to monkey with the Apache settings and cause our whole website to cease to function, so I thought I'd ask the question: can you have more than one CGI parser called by .cgi?

I want to test the Livecode Server against a cgi that I know causes the "fast computer display problem" I note above, but I want to be sure it won't cause an issue with my setup.

Any insight or help would be appreciated.

Stryder

Pyrros
Posts: 9
Joined: Sun Apr 20, 2014 8:26 pm

Re: Livecode CGIs co-existing with old-school Rev 2.x CGIs

Post by Pyrros » Fri Jul 18, 2014 10:52 pm

Hi

I can't see why you can't have multiple versions of LiveCode running under Apache. It should work in a simliar fashion to how you can setup multiple versions of PHP, just take a look in google there should be a number of examples that you can adapt. You just won't be able to run them at the same time on the same site / domain. I would look at setting up a different version on a subdomain and then test from there.

Kind Regards
Simon

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 8474
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Livecode CGIs co-existing with old-school Rev 2.x CGIs

Post by FourthWorld » Fri Jul 18, 2014 11:47 pm

As of v6.6 the hash-bang style has been restored to LiveCode Server:
http://livecode.com/blog/2014/03/06/livecode-server/
Richard Gaskin
LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Peter Wood
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 92
Joined: Mon Jul 06, 2009 4:53 am
Location: Bamboo River

Re: Livecode CGIs co-existing with old-school Rev 2.x CGIs

Post by Peter Wood » Sat Jul 19, 2014 12:59 am

At the moment, it appears that you cannot run "old-fashioned" cgi scripts with LiveCode Server 6.6.1. The LiveCode server process does not end (even with a quit in the script) and has to be cancelled.

I found this by trying the following simple script:

Code: Select all

#!/<full path to>/livecode-server

set the outputLineEndings to "lf"
put "Content-type: text/html" & crlf & crlf
put "<p>Hello from a LiveCodeServer CGI script</p>" & return
quit
The script runs correctly from the command line:

Code: Select all

$ ./livecode.cgi
Content-type: text/html

<p>Hello from a LiveCodeServer CGI script</p>
I ran the script on OS X 10.9.4 with LiveCodeServer 6.6.1

If somebody can confirm this I'll submit a bug report.

Stryder
Posts: 27
Joined: Fri Jul 21, 2006 12:05 pm
Location: Winnipeg, Canada

Re: Livecode CGIs co-existing with old-school Rev 2.x CGIs

Post by Stryder » Sat Jul 19, 2014 1:47 am

FourthWorld wrote:As of v6.6 the hash-bang style has been restored to LiveCode Server:
http://livecode.com/blog/2014/03/06/livecode-server/
Wow, nice to see the return of hash-bang! I didn't know that. Thanks!!

Peter Wood
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 92
Joined: Mon Jul 06, 2009 4:53 am
Location: Bamboo River

Re: Livecode CGIs co-existing with old-school Rev 2.x CGIs

Post by Peter Wood » Sun Aug 10, 2014 10:05 am

The problem with running CGIs with a shebang with LiveCode Server has been fixed in LiveCode 6.8.0 DP 8 and LiveCode 7.0.0 DP 7. So the following CGI script now runs happily:

Code: Select all

#!/path-to/livecode-server

put header "Content-type: text/html" & crlf & crlf
put "<p>Hello from a LiveCodeServer CGI script</p>" & return

So to answer Stryder's original question, getting you old school 2.x CGI scripts to run under LiveCodeServer should simply be a matter of installing LiveCode Server, changing the shebang line and removing the "on startup" and "end startup" lines.

Stryder
Posts: 27
Joined: Fri Jul 21, 2006 12:05 pm
Location: Winnipeg, Canada

Re: Livecode CGIs co-existing with old-school Rev 2.x CGIs

Post by Stryder » Sun Aug 10, 2014 1:25 pm

Peter Wood wrote:The problem with running CGIs with a shebang with LiveCode Server has been fixed in LiveCode 6.8.0 DP 8 and LiveCode 7.0.0 DP 7. So the following CGI script now runs happily:

Code: Select all

#!/path-to/livecode-server

put header "Content-type: text/html" & crlf & crlf
put "<p>Hello from a LiveCodeServer CGI script</p>" & return

So to answer Stryder's original question, getting you old school 2.x CGI scripts to run under LiveCodeServer should simply be a matter of installing LiveCode Server, changing the shebang line and removing the "on startup" and "end startup" lines.
Thanks Peter!

One question, though: I have functions at the bottom of my cgi scripts after 'end startup'. How do I embed my functions if I don't have an 'end startup'?

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 8474
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Livecode CGIs co-existing with old-school Rev 2.x CGIs

Post by FourthWorld » Sun Aug 10, 2014 4:07 pm

Oddly enough, IIRC you can just put handlers below the main block and the engine will find them. Personally I'd prefer if they at least allowed us to use an explicit startup message at before as am option, but I haven't filled a request for that yet
Richard Gaskin
LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Peter Wood
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 92
Joined: Mon Jul 06, 2009 4:53 am
Location: Bamboo River

Re: Livecode CGIs co-existing with old-school Rev 2.x CGIs

Post by Peter Wood » Mon Aug 11, 2014 6:57 am

Personally, out of habit from coding in other languages, I put the handlers before the "main" code. The following example works:

Code: Select all

#!/path-to/livecode-server

#handlers
on welcome
 put "<p>Hello from a LiveCodeServer CGI script</p>" & return
end welcome

# main cgi script
put header "Content-type: text/html" & crlf & calf
welcome


Post Reply

Return to “CGIs and the Server”