From: Sam Duncan Date: 2012-04-13T11:32:43+09:00 Subject: Re: Change the value of a variable inside a running ruby program. On 13/04/12 13:38, Matthew Smith wrote: > I have a program that is running constantly and I'd like to be able to > change the value of a variable inside it from the outside by doing > something on the command line. > > Ideally, this would happen via an interrupt process so that the program > doesn't have to continuously poll some resource. > > Right now, the program just polls mysql every few seconds to see if > someone has changed a setting which is stored in a table. Ideally, I'd > like the program to read from the table on startup but then not have to > poll mysql anymore to see if the setting has been changed. > > Hopefully I'm making sense here... > Could you just use a HUP, SIGUSR1 or 2 signal handler to set the flag? Either it causes the app to reread the value from the database, or if it is just a toggle/ dual state item, simply switches it based on which signal it gets? Sam