Re: What is elegant way to do configuration on server app

2015-03-27 Thread CHIN Dihedral
On Thursday, March 26, 2015 at 4:19:33 PM UTC+8, Jerry OELoo wrote: > Hi. > I have used python to provide a web service app, it will running 7*24, > and it will return some data to client by API. http://jonpy.sourceforge.net/modpy.html Check the page of modpy and django. -- https://mail.python.o

Re: What is elegant way to do configuration on server app

2015-03-27 Thread Grant Edwards
On 2015-03-27, Chris Angelico wrote: > The same problem occurs with PHP-based web sites, but there you don't > get the option of holding over for a SIGHUP, so you're just stuck with > uploading a new version of your site file-by-file, or *maybe* > attempting an atomic rename of a directory. If yo

Re: What is elegant way to do configuration on server app

2015-03-27 Thread Marko Rauhamaa
Grant Edwards : > On 2015-03-27, Marko Rauhamaa wrote: >> That, indeed, is the classic Unix way. However, Linux has now moved >> to systemd: > > That's a bit of an overstatement. _Some_ distros have switched to > systemd. None of my machines use it, and it's very rare in embedded > systems. Much

Re: What is elegant way to do configuration on server app

2015-03-27 Thread Chris Angelico
On Sat, Mar 28, 2015 at 3:28 AM, Grant Edwards wrote: > I presume that automagically reading them any time they changed was > both too much hassle and possibly dangerous: if a file is being > edited, it might get saved in intermediate (broken) states during the > editing session. Even more so if

Re: What is elegant way to do configuration on server app

2015-03-27 Thread Grant Edwards
On 2015-03-27, Marko Rauhamaa wrote: > Grant Edwards : > >> That sounds rather Windowsesque. The more-or-less standard way to do >> handle the situation on Unix is to reread the config file when you get >> a SIGHUP. > > That, indeed, is the classic Unix way. However, Linux has now moved to > syste

Re: What is elegant way to do configuration on server app

2015-03-27 Thread Grant Edwards
On 2015-03-27, Jerry OELoo wrote: >>> Make a part of your event loop (assuming your server runs an event >>> loop) that wakes up every N seconds (e.g. every 60 seconds) and >>> checkes the file's modification timestamp again; if it's newer, record >>> that value for future comparisons, th

Re: What is elegant way to do configuration on server app

2015-03-27 Thread Chris Angelico
On Sat, Mar 28, 2015 at 12:23 AM, Marko Rauhamaa wrote: > Chris Angelico : > >> The number of cases where this matters is fairly low. Doing the reload >> asynchronously is generally sufficient. > > Not sure. Not sure at all. Issues like this occupy a great part of my > office hours. Only because

Re: What is elegant way to do configuration on server app

2015-03-27 Thread Marko Rauhamaa
Chris Angelico : > The number of cases where this matters is fairly low. Doing the reload > asynchronously is generally sufficient. Not sure. Not sure at all. Issues like this occupy a great part of my office hours. > And even if you have something that waits for the reload to finish, > you'll u

Re: What is elegant way to do configuration on server app

2015-03-27 Thread Chris Angelico
On Fri, Mar 27, 2015 at 7:47 PM, Marko Rauhamaa wrote: > Grant Edwards : > >> That sounds rather Windowsesque. The more-or-less standard way to do >> handle the situation on Unix is to reread the config file when you get >> a SIGHUP. > > That, indeed, is the classic Unix way. However, Linux has no

Re: What is elegant way to do configuration on server app

2015-03-27 Thread Marko Rauhamaa
Grant Edwards : > That sounds rather Windowsesque. The more-or-less standard way to do > handle the situation on Unix is to reread the config file when you get > a SIGHUP. That, indeed, is the classic Unix way. However, Linux has now moved to systemd: ExecReload= Commands to execute t

Re: What is elegant way to do configuration on server app

2015-03-27 Thread Chris Angelico
On Fri, Mar 27, 2015 at 7:28 PM, Jerry OELoo wrote: > Hi Grant: > Why use SIGHUP, Does it has something to do with configure file > modification? I don't get it. Thank you. Long tradition. I have no idea why that particular signal is used, but it's a well-known convention. In any case, it's certa

Re: What is elegant way to do configuration on server app

2015-03-27 Thread Jerry OELoo
Hi Grant: Why use SIGHUP, Does it has something to do with configure file modification? I don't get it. Thank you. On Thu, Mar 26, 2015 at 11:49 PM, Grant Edwards wrote: > On 2015-03-26, Ben Finney wrote: >> Jerry OELoo writes: >> >>> Currently, I can just think out that I put status into a con

Re: What is elegant way to do configuration on server app

2015-03-26 Thread Grant Edwards
On 2015-03-26, Ben Finney wrote: > Jerry OELoo writes: > >> Currently, I can just think out that I put status into a configure >> file, and service schedule read this file and get status value, > > That sounds like a fine start. Some advice: > > * You may be tempted to make the configuration file

Re: What is elegant way to do configuration on server app

2015-03-26 Thread Ben Finney
Jerry OELoo writes: > Currently, I can just think out that I put status into a configure > file, and service schedule read this file and get status value, That sounds like a fine start. Some advice: * You may be tempted to make the configuration file executable (e.g. Python code). Resist that

What is elegant way to do configuration on server app

2015-03-26 Thread Jerry OELoo
Hi. I have used python to provide a web service app, it will running 7*24, and it will return some data to client by API. Now I want to add some extra data in return data, ex, "status = 1", and I want this value 1 can be configured, that means I can control that service app return status with 0, 1