Page 1 of 1

Can we create a Windows service with Livecode?

Posted: Wed Aug 12, 2020 3:51 pm
by karmacomposer
I would like to convert one of my desktop apps made with Livecode into a running service so it can run seamlessly in the background and not be easily shut down to ward against hackers and breaches.

Can this be done on Windows? Mac? Linux?

Thanks.

Mike

Re: Can we create a Windows service with Livecode?

Posted: Wed Aug 12, 2020 4:45 pm
by dunbarx
Hi.

I am not sure what you are asking for, but a running standalone will, er, run in the background all by its lonesome.

I made a test stack long ago, and just found it again. All it does is start a counter that increments a field a few times per second. The process can only be stopped if you press the optionKey. If I start it running, and then go to any other app, like the Finder, Excel or Safari, it increments. If, still in one of those other apps, I press the optionKey, it stops.

Craig

Re: Can we create a Windows service with Livecode?

Posted: Wed Aug 12, 2020 5:09 pm
by ghettocottage
Running an application as a service (or daemon in linux) has some advantages, for example:
It is running for all users rather than just the user you are logged in as when you manually start an application
It can auto-start at boot rather than having to have a particular user logged in (preferable for headless servers and such)

My linux desktop acts as a server in my house and I have quite a few applications running as a daemon. Plenty of online tutorials how to set up with system.d or init (for older versions).

In Windows I am not sure, but 4 years ago I set up a simple batch script as a service and do not remember it being too difficult. I had to use the Windows Scheduler to set it up.

Re: Can we create a Windows service with Livecode?

Posted: Wed Aug 12, 2020 5:30 pm
by mrcoollion
Here are some links that might offer a solution.

https://www.howtogeek.com/50786/using-s ... s-service/

https://robotronic.de/runasserviceen.html

Regards,

Paul

Re: Can we create a Windows service with Livecode?

Posted: Wed Aug 12, 2020 6:15 pm
by karmacomposer
mrcoollion wrote:
Wed Aug 12, 2020 5:30 pm
Here are some links that might offer a solution.

https://www.howtogeek.com/50786/using-s ... s-service/

https://robotronic.de/runasserviceen.html

Regards,

Paul
Those links are perfect. Thank you.

Second question:

I would prefer to run the program's contents inside a openStack command but if I do, it makes compiling impossible because it starts up right away and locks me out.

The app is copying files from one location to another using TsNet.

How do I start Livecode so that a openStack (or openCard) command does not execute immediately and allows me to compile?

Thanks.

Mike

Re: Can we create a Windows service with Livecode?

Posted: Wed Aug 12, 2020 9:24 pm
by FourthWorld
karmacomposer wrote:
Wed Aug 12, 2020 6:15 pm
How do I start Livecode so that a openStack (or openCard) command does not execute immediately and allows me to compile?
The environment function will return "development" when in the IDE, e.g.:

Code: Select all

on openStack
   if "dev" is in the environment then exit openStack
   DoSomethingAtRuntime
end openStack

Re: Can we create a Windows service with Livecode?

Posted: Wed Aug 12, 2020 11:49 pm
by karmacomposer
FourthWorld wrote:
Wed Aug 12, 2020 9:24 pm
karmacomposer wrote:
Wed Aug 12, 2020 6:15 pm
How do I start Livecode so that a openStack (or openCard) command does not execute immediately and allows me to compile?
The environment function will return "development" when in the IDE, e.g.:

Code: Select all

on openStack
   if "dev" is in the environment then exit openStack
   DoSomethingAtRuntime
end openStack
So it quits openStack which then allows me to compile, correct?

The DoSomethingAtRuntime is the rest of the routine, correct?

Thank you.

Mike

Re: Can we create a Windows service with Livecode?

Posted: Thu Aug 13, 2020 4:21 am
by FourthWorld
Yes, and yes. It does what it appears to do.

When in doubt try it and see what happens...

Re: Can we create a Windows service with Livecode?

Posted: Fri Aug 14, 2020 10:14 am
by sphere
karmacomposer wrote:
Wed Aug 12, 2020 6:15 pm
How do I start Livecode so that a openStack (or openCard) command does not execute immediately and allows me to compile?
You could also first turn Messages Off in the IDE, and the load it. Nothing will work from your stack then.
You can build an exe.

Re: Can we create a Windows service with Livecode?

Posted: Fri Aug 14, 2020 2:00 pm
by karmacomposer
sphere wrote:
Fri Aug 14, 2020 10:14 am
karmacomposer wrote:
Wed Aug 12, 2020 6:15 pm
How do I start Livecode so that a openStack (or openCard) command does not execute immediately and allows me to compile?
You could also first turn Messages Off in the IDE, and the load it. Nothing will work from your stack then.
You can build an exe.
That does not work when the main functions are both in openStack and opencard.

On or off does not seem to matter, unless messages are somewhere else entirely. Where do you turn messages on or off? If it's the same as running your app or not, does not matter.

Fourthworld's advice, with some tweaking, worked for me. I had to use the long word "development" and specify "standalone application" as well.

Mike

Re: Can we create a Windows service with Livecode?

Posted: Fri Aug 14, 2020 6:57 pm
by sphere
Close and remove all stacks from memory.
There is a big button in the upper bar of the ide, messages. When it's turned off and then you load your stack. Nothing of the stack will work. Untill you turn it on again.
At least on all lc ide's i had installed here, it worked that way.

Re: Can we create a Windows service with Livecode?

Posted: Fri Aug 14, 2020 7:39 pm
by FourthWorld
karmacomposer wrote:
Fri Aug 14, 2020 2:00 pm
Fourthworld's advice, with some tweaking, worked for me. I had to use the long word "development" and specify "standalone application" as well.
The "is in" operator works on substrings, so as written the long form of "development" would not be needed. It would be needed if you replaced "is in" with "is", but as written it works; I use it daily here.