Changeset 4066
- Timestamp:
- 02/15/09 22:21:55 (4 years ago)
- Location:
- branch/NetworkInventory
- Files:
-
- 2 modified
-
umit-scheduler (modified) (5 diffs)
-
umitCore/Scheduler.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branch/NetworkInventory/umit-scheduler
r4034 r4066 1 1 #!/usr/bin/env python 2 2 # -*- coding: utf-8 -*- 3 # 3 4 4 # Copyright (C) 2007 Insecure.Com LLC. 5 5 # … … 10 10 # the Free Software Foundation; either version 2 of the License, or 11 11 # (at your option) any later version. 12 # 12 # 13 13 # This program is distributed in the hope that it will be useful, 14 14 # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 16 # GNU General Public License for more details. 17 # 17 # 18 18 # You should have received a copy of the GNU General Public License 19 19 # along with this program; if not, write to the Free Software … … 59 59 Show help 60 60 """ 61 print _("Use:") + (" %s start|stop|cleanup <config_dir>" % __file__)61 print _("Use:") + (" %s start|stop|cleanup <config_dir>" % sys.argv[0]) 62 62 63 63 … … 128 128 log.debug(">>> Scheduler is stopped already, removing control file..") 129 129 remove_controlfile() 130 130 131 131 log.debug(">>> Cleanup finished") 132 132 133 133 134 134 def start(): … … 139 139 sys.exit(0) 140 140 141 process = subprocess.Popen([sys.executable, Scheduler.__file__,142 sys.path[0], 'start', HOME_CONF])141 from umitCore import Scheduler 142 from umitCore.BGProcess import run_on_background 143 143 144 pid = process.pid144 run_on_background() 145 145 146 log.debug(">>> Starting Scheduler..") 147 log.debug(">>> Writing pid (%d) to %s" % (pid, RUNNING_FILE)) 146 pid = os.getpid() 148 147 149 148 f_run = open(RUNNING_FILE, 'w') 150 149 f_run.write("%d" % pid) 151 150 f_run.close() 151 152 Scheduler.main('start', sys.path[0], HOME_CONF) 152 153 153 154 -
branch/NetworkInventory/umitCore/Scheduler.py
r4034 r4066 8 8 # the Free Software Foundation; either version 2 of the License, or 9 9 # (at your option) any later version. 10 # 10 # 11 11 # This program is distributed in the hope that it will be useful, 12 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 14 # GNU General Public License for more details. 15 # 15 # 16 16 # You should have received a copy of the GNU General Public License 17 17 # along with this program; if not, write to the Free Software … … 27 27 import signal 28 28 import warnings 29 from os.path import join30 29 from ConfigParser import ConfigParser 31 30 … … 58 57 def check_for_changes(self): 59 58 """ 60 If schemas file or profiles file changed since last check, 59 If schemas file or profiles file changed since last check, 61 60 reparse schemas. 62 61 """ … … 630 629 if running_scans: 631 630 scans_count = len(running_scans) 632 log.debug("%d scan%s to cleanup" % (scans_count, 631 log.debug("%d scan%s to cleanup" % (scans_count, 633 632 (scans_count > 1) and 's' or '')) 634 633 … … 666 665 667 666 668 if __name__ == "__main__": 669 sys.path.insert(0, sys.argv[1]) 670 667 def main(cmd, base_path, home_conf): 668 sys.path.insert(0, base_path) 671 669 from umitCore.Paths import Path 672 Path.set_umit_conf( join(sys.argv[3]), True)670 Path.set_umit_conf(home_conf, True) 673 671 674 672 from umitCore.UmitLogging import file_log … … 680 678 681 679 log = file_log(Path.sched_log) 682 683 umitdb_ng = Path.umitdb_ng680 681 globals().update(locals()) 684 682 685 683 if os.name == "posix": 686 684 signal.signal(signal.SIGHUP, safe_shutdown) 687 688 685 signal.signal(signal.SIGTERM, safe_shutdown) 689 686 signal.signal(signal.SIGINT, safe_shutdown) 690 687 691 cmds = { "start": start } 692 693 cmds[sys.argv[2]]() 694 688 cmds = {'start': start} 689 cmds[cmd]() 690 691 if __name__ == "__main__": 692 main(*sys.argv)
