def setup(opts=None):
	"""Parse options. If none given, opts is set to sys.argv"""
	if opts is None:
		opts = sys.argv[1:]
	config.bootstrap(opts)
	config.load()
	config.parse_options(opts)
	ensure_dir_exists(app_globals.OPTIONS['output_path'])
	log_start()
	if app_globals.OPTIONS['report_pid']:
		proctl.report_pid()
		exit(0)
	config.check()
	proctl.ensure_singleton_process()
	init_signals()
	def test_should_report_pid_if_there_is_a_running_process(self):
		self.mock_pid_process(pid=1234)
		proctl.report_pid()
		self.assertEqual(sys.stdout.write.call_args_list, [(('1234',), {}), (('\n',), {})])
	def test_should_print__none__if_there_is_no_pid_running(self):
		self.mock_pid_process(pid=None)
		proctl.report_pid()
		self.assertEqual(sys.stdout.write.call_args_list, [(('None',), {}), (('\n',), {})])
	def test_should_print__none__if_there_is_an_error(self):
		proctl.get_running_pid = self.fail
		proctl.report_pid()
		self.assertEqual(sys.stdout.write.call_args_list, [(('None',), {}), (('\n',), {})])