App lifecycle

8 views
Skip to first unread message

dxgriffiths

unread,
Apr 14, 2011, 5:00:14 AM4/14/11
to akshell
Hi guys,

I'm noodling around with the Eval function and wondering what's the
actual lifecycle of an Akshell app? Does main.js get run once and
persist? Or does it get re-executed every time a URL is requested?

David

Oleg Podsechin

unread,
Apr 14, 2011, 5:39:26 AM4/14/11
to aks...@googlegroups.com
Apps don't persist monolithically. Each time a request is made to your app domain, a new server process based on your main.js will be spawned if one doesn't exist already, or if all existing processes are busy. Once spawned, processes persist until they are no longer needed.

So, you should not use main.js to persist anything that you wouldn't want to lose or have in an inconsistent state, including HTTP session data. The database (http://www.akshell.com/docs/0.3/guide/db/) should be used for that (at the moment).

The only types of variable to store in main.js are ones that are process specific that need to be initialized once. Say you had locale strings in a text file in a key=value format and you wanted to store them inside the app as a JSON object, rather than parsing them on every request. They could be lazily loaded in main.js and stored as a variable. That way when a new process is spawned, it would lazily reinitialize the JSON object in exactly the same way, ensuring consistency across processes.

Oleg


--
You received this message because you are subscribed to the Google Groups "akshell" group.
To post to this group, send email to aks...@googlegroups.com.
To unsubscribe from this group, send email to akshell+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akshell?hl=en.


Dash

unread,
Apr 14, 2011, 6:19:13 AM4/14/11
to akshell
Ok that makes sense, thanks.
Reply all
Reply to author
Forward
0 new messages