diff options
author | Philip Knirsch <pknirsch@hamburg.stuttgart.redhat.com> | 2009-02-25 11:28:06 +0100 |
---|---|---|
committer | Philip Knirsch <pknirsch@hamburg.stuttgart.redhat.com> | 2009-02-25 11:28:06 +0100 |
commit | 1fa57228447abc46d58bcc377ab373c026ccd008 (patch) | |
tree | 634135e6c1c62729feb2893a38d7b2da0d89784e /tuned | |
parent | e393e728bcffd730401780a8fb3d077d952fed78 (diff) | |
download | tuned-1fa57228447abc46d58bcc377ab373c026ccd008.tar.gz tuned-1fa57228447abc46d58bcc377ab373c026ccd008.tar.xz tuned-1fa57228447abc46d58bcc377ab373c026ccd008.zip |
- Add init() methods to each plugin
- Call plugin init() methods during tuned's init()
- Add support for command line parameters
o -c conffile|--config==conffile to specify the location of the config file
o -d to start tuned as a daemon (instead of as normal app)
- Readded the debug output in case tuned isn't started as as daemon
- Fixed initialization of max transfer values for net tuning plugin
Diffstat (limited to 'tuned')
-rwxr-xr-x | tuned | 34 |
1 files changed, 31 insertions, 3 deletions
@@ -20,9 +20,12 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # -import sys, os.path +import sys, os.path, getopt -if __name__ == "__main__": +def usage(): + print "Usage: tuned [-d|--daemon] [-c conffile|--config=conffile]" + +def daemonize(): try: pid = os.fork() if pid > 0: @@ -42,12 +45,37 @@ if __name__ == "__main__": sys.exit(1) sys.stdout = sys.stderr = open("/dev/null", 'a+') + +if __name__ == "__main__": + try: + opts, args = getopt.getopt(sys.argv[1:], "dc:", ["daemon", "config="]) + except getopt.error, e: + print >>sys.stderr, ("Error parsing command-line arguments: %s", e) + usage() + sys.exit(1) + + if len(args) > 0: + print >>sys.stderr, ("Too many arguments.") + usage() + sys.exit(1) + + daemon = False + cfgfile = "/etc/tuned.conf" + for (opt, val) in opts: + if opt in ['-d', "--daemon"]: + daemon = True + elif opt in ['-c', "--config"]: + cfgfile = val + + if daemon: + daemonize() + TUNEDDIR="/usr/share/tuned" if not TUNEDDIR in sys.path: sys.path.append(TUNEDDIR) from tuned import tuned - tuned.init(TUNEDDIR) + tuned.init(TUNEDDIR, cfgfile) tuned.run() tuned.cleanup() |