LUX and memory consumption

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

LUX and memory consumption

Jolle Carlestam-2
Regardless of how much I love LUX there are some downsides to using it. Main concern that it can cause substantial strains on my local computer and memory.

This morning I came back to my machine finding a dialog, I’ve never seen before, saying that the computer had run out of application memory and urged me to quit applications. This on a machine with 16GB of RAM and a fusion drive disk with plenty of room. Checking what process that was eating memory I found that two LUX related calls each considered themselves in need of +15GB of memory…?!
I have found that if I happen to leave a LUX window open in the Instance Dashboard view, Safari will go very slow and unresponsive after a while. This clashes with the convenience of having the view at hand for any install I have since a frequent need while developing is to restart an instance. Thus I tend to have three tabs with LUX open at any time. Each pointing on a different server.

Would be lovely if Lassosoft could put it high on the list to fix and release a version of LUX that did not cause memory leaks.

Since I imagine that could take a while, (Where’s Jono when you need him?) is there another convenient way of restarting an instance, for example from command line?

HDB
Jolle

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: LUX and memory consumption

Ke Carlton-3
sys_exit(0) will restart an instance —perhaps you leverage that for
restarting?


On Fri, Jan 15, 2016 at 12:21 AM Jolle Carlestam <[hidden email]>
wrote:

> Regardless of how much I love LUX there are some downsides to using it.
> Main concern that it can cause substantial strains on my local computer and
> memory.
>
> This morning I came back to my machine finding a dialog, I’ve never seen
> before, saying that the computer had run out of application memory and
> urged me to quit applications. This on a machine with 16GB of RAM and a
> fusion drive disk with plenty of room. Checking what process that was
> eating memory I found that two LUX related calls each considered themselves
> in need of +15GB of memory…?!
> I have found that if I happen to leave a LUX window open in the Instance
> Dashboard view, Safari will go very slow and unresponsive after a while.
> This clashes with the convenience of having the view at hand for any
> install I have since a frequent need while developing is to restart an
> instance. Thus I tend to have three tabs with LUX open at any time. Each
> pointing on a different server.
>
> Would be lovely if Lassosoft could put it high on the list to fix and
> release a version of LUX that did not cause memory leaks.
>
> Since I imagine that could take a while, (Where’s Jono when you need him?)
> is there another convenient way of restarting an instance, for example from
> command line?
>
> HDB
> Jolle
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>   the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: LUX and memory consumption

Jolle Carlestam-2
I had a chat with Ke earlier today in Lassos Gitter room. Based on feedback and thoughts there I came up with the following to allow restarting instances without using LUX.

My aim is to have a solution that works in the CLI. Thus have it working without the need for opening LUX and without having to use quick code or any instance specific page. Instance could for all I know be down and that is one advantage of LUX, that it operates completely independent of the instances.

Using the CLI renders sys_exit useless since it will only operate on the instance from which it is called. There are however other means.

The idea is that we let the instance create a file whenever it is initiated that contains the active PID. (A thingy that identifies the process the instance run in.)

This file is then retrieved from a command line script that uses it to kill the process in question.

CODE

Put a file in each LassoStartup folder for any instance you want to be able to restart from CLI that looks like this:

[
/*
snippet to create a PID file used for CLI restarts of instance
*/
local(f) = file(admin_lassoservicepath + 'pid.txt')
#f -> exists ? #f->delete
#f -> writebytes(bytes(string(sys_getpid)))
#f -> close
log_critical('PID file created ' + string(sys_getpid))
]

Mine is called createpidfile.lasso
Having it in the instance LassoStartup will ensure that it is executed each time the instance starts. And, as a perk, that it will be run very late in the process.
It will create a file ”pid.txt" in the instance directory. A place that is always owned by the user that that particular instance runs under and therefore always writable by the instance. Thus no need to worry about permissions to create it.


Next, create a file on the same machine as your Lasso install, be that your local machine or the server. Where you put it is up to you. I have mine in a folder called cli in /var/lasso/. It’s the place where I keep all my CLI Lasso scripts. Mine is called restartinstance.

The content can be like this:

#!/usr/bin/env lasso9
// Important that the file starts with the above row. NO BOM!!

local(
        timeoutmillis = millis + 600000,
        continue = true,
        path, holder, whoami, pidfile, pid, sysprocess
)

#sysprocess = sys_process('/usr/bin/whoami' )
#holder = #sysprocess -> wait
#whoami = #sysprocess -> readstring

#sysprocess -> close

#whoami -> trim

if(#whoami != 'root') => {
        stdout('You need to run this command as root. Try again.')
        return
}
// What instance?
stdout('Give instance name or path to instance that should be restarted: ')

// The following bits wait until the terminal gives you back a line of input
while(not #path or #path -> size == 0) => {
        #path = string(file_stdin -> readSomeBytes(1024, 1000))
}
#path -> trim

// If path does not start with a slash, assume it’s an instance name
if(not #path -> beginswith('/')) => {
        #path = '//var/lasso/instances/' + #path
}

not #path -> endswith('/') ? #path -> append('/')

#pidfile = file(#path + 'pid.txt')

if(#pidfile -> exists) => {
        #pid = #pidfile -> readstring
        stdout('Found the instance pid ' + #pid + '. Restarting: ')
        #sysprocess = sys_process('/bin/kill', (: #pid) )
        #holder = #sysprocess -> wait
        #holder = #sysprocess -> readError -> asstring
        #sysprocess -> close

        if(#holder) => {
                stdout('\nError: ' + #holder)
        else
                #pidfile -> delete
                while(#continue) => {
                        stdout('.')
                        if(millis > #timeoutmillis) => {
                                #continue = false
                                stdout('\nTimed out waiting for instance to come back online.')
                                return
                        }
                        if(#pidfile -> exists) => {
                                #continue = false
                                stdout('\nInstance is back online. New PID: ' + #pidfile -> readstring)
                                return
                        }
                        sleep(5000)
                }
        }

else
        stdout('Did not find a pid file at given path')
}

——
That’s all code you need. Note, in order for it to work the first time, the instance must have been restarted with the createpidfile.lasso in place.

Also important is that you need to call the restartinstance script as root. Sudo works fine. this is because the kill command that lasso calls does not allow you to kill processes that is not yours.

Here’s how it can look when all is working:

jolle:lasso jolle$ sudo /var/lasso/cli/restartinstance
Give instance name or path to instance that should be restarted: default
Found the instance pid 81196. Restarting: ........................
Instance is back online. New PID: 81205
jolle:lasso jolle$

Looks good to me! :-) Enjoy!

HDB
Jolle


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: LUX and memory consumption

Jolle Carlestam-2
14 jan 2016 kl. 17:28 skrev Jolle Carlestam <[hidden email]>:
>
> Also important is that you need to call the restartinstance script as root. Sudo works fine. this is because the kill command that lasso calls does not allow you to kill processes that is not yours.

I forgot one tiny but important piece of information. You need to make the file executable. Different ways to skin that cat, but here’s how I do it. On the CLI:

sudo chmod ug+x restartinstance

HDB
Jolle

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: LUX and memory consumption

Carl Ketterling
In reply to this post by Jolle Carlestam-2
VERY  nice!  Thank you!



From: Jolle Carlestam <[hidden email]>
Reply-To: <[hidden email]>
Date: Thu, 14 Jan 2016 17:28:47 +0100
To: <[hidden email]>
Subject: Re: LUX and memory consumption

I had a chat with Ke earlier today in Lassos Gitter room. Based on feedback
and thoughts there I came up with the following to allow restarting
instances without using LUX. My aim is to have a solution that works in the
CLI. Thus have it working without the need for opening LUX and without
having to use quick code or any instance specific page. Instance could for
all I know be down and that is one advantage of LUX, that it operates
completely independent of the instances. Using the CLI renders sys_exit
useless since it will only operate on the instance from which it is called.
There are however other means. The idea is that we let the instance create a
file whenever it is initiated that contains the active PID. (A thingy that
identifies the process the instance run in.) This file is then retrieved
from a command line script that uses it to kill the process in question.
CODE Put a file in each LassoStartup folder for any instance you want to be
able to restart from CLI that looks like this: [ /* snippet to create a PID
file used for CLI restarts of instance */ local(f) =
file(admin_lassoservicepath + 'pid.txt') #f -> exists ? #f->delete #f ->
writebytes(bytes(string(sys_getpid))) #f -> close log_critical('PID file
created ' + string(sys_getpid)) ] Mine is called createpidfile.lasso Having
it in the instance LassoStartup will ensure that it is executed each time
the instance starts. And, as a perk, that it will be run very late in the
process. It will create a file ²pid.txt" in the instance directory. A place
that is always owned by the user that that particular instance runs under
and therefore always writable by the instance. Thus no need to worry about
permissions to create it. Next, create a file on the same machine as your
Lasso install, be that your local machine or the server. Where you put it is
up to you. I have mine in a folder called cli in /var/lasso/. It¹s the place
where I keep all my CLI Lasso scripts. Mine is called restartinstance. The
content can be like this: #!/usr/bin/env lasso9 // Important that the file
starts with the above row. NO BOM!! local(  timeoutmillis = millis + 600000,
continue = true,  path, holder, whoami, pidfile, pid, sysprocess )
#sysprocess = sys_process('/usr/bin/whoami' ) #holder  = #sysprocess -> wait
#whoami  = #sysprocess -> readstring #sysprocess -> close #whoami -> trim
if(#whoami != 'root') => {  stdout('You need to run this command as root.
Try again.')  return } // What instance? stdout('Give instance name or path
to instance that should be restarted: ') // The following bits wait until
the terminal gives you back a line of input while(not #path or #path -> size
== 0) => {  #path = string(file_stdin -> readSomeBytes(1024, 1000)) } #path
-> trim // If path does not start with a slash, assume it¹s an instance name
if(not #path -> beginswith('/')) => {  #path = '//var/lasso/instances/' +
#path } not #path -> endswith('/') ? #path -> append('/') #pidfile =
file(#path + 'pid.txt') if(#pidfile -> exists) => {  #pid = #pidfile ->
readstring  stdout('Found the instance pid ' + #pid + '. Restarting: ')
#sysprocess = sys_process('/bin/kill', (: #pid) )  #holder  = #sysprocess ->
wait  #holder  = #sysprocess -> readError -> asstring  #sysprocess -> close
if(#holder) => {   stdout('\nError: ' + #holder)  else   #pidfile -> delete
while(#continue) => {    stdout('.')    if(millis > #timeoutmillis) => {
#continue = false     stdout('\nTimed out waiting for instance to come back
online.')     return    }    if(#pidfile -> exists) => {     #continue =
false     stdout('\nInstance is back online. New PID: ' + #pidfile ->
readstring)     return    }    sleep(5000)   }  } else  stdout('Did not find
a pid file at given path') } ‹‹ That¹s all code you need. Note, in order for
it to work the first time, the instance must have been restarted with the
createpidfile.lasso in place. Also important is that you need to call the
restartinstance script as root. Sudo works fine. this is because the kill
command that lasso calls does not allow you to kill processes that is not
yours. Here¹s how it can look when all is working: jolle:lasso jolle$ sudo
/var/lasso/cli/restartinstance Give instance name or path to instance that
should be restarted: default Found the instance pid 81196. Restarting:
........................ Instance is back online. New PID: 81205 jolle:lasso
jolle$ Looks good to me! :-) Enjoy! HDB Jolle
############################################################# This message
is sent to you because you are subscribed to  the mailing list Lasso
[hidden email] Official list archives available at
http://www.lassotalk.com To unsubscribe, E-mail to:
<[hidden email]> Send administrative queries to
<[hidden email]>


#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: LUX and memory consumption

Ke Carlton-3
In reply to this post by Jolle Carlestam-2
Another perk is you can then you the generated PID file for things like
Monit to automatically manage your instance.

On Fri, Jan 15, 2016 at 5:28 AM Jolle Carlestam <[hidden email]> wrote:

>
> Having it in the instance LassoStartup will ensure that it is executed
> each time the instance starts. And, as a perk, that it will be run very
> late in the process.
> It will create a file ”pid.txt" in the instance directory. A place that is
> always owned by the user that that particular instance runs under and
> therefore always writable by the instance. Thus no need to worry about
> permissions to create it.
>
>
>

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: LUX and memory consumption

Jolle Carlestam-2
14 jan 2016 kl. 21:28 skrev Ke Carlton <[hidden email]>:
>
> Another perk is you can then you the generated PID file for things like
> Monit to automatically manage your instance.

What a good idea!

A good day for a lot of reasons.

HDB
Jolle

pst, By the way. I am totally in love with Eric!!

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>