10 examples of 'python restart script' in Python

Every line of 'python restart script' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
31def restart(time=0,force=False):
32 # TODO: solve unix version problem
33 '''
34
35 :param time: int , Time in second for restart
36 :param force: bool ,True for Force restart
37 :return: bool , True (Successfully) False(Unsuccessfully)
38 '''
39 command="shutdown -r "
40 try:
41 if force==True:
42 command+="-f "
43 response=sub.Popen(command+"-t "+str(time),shell=True,stdin=sub.PIPE,stdout=sub.PIPE,stderr=sub.PIPE)
44 response = list(response.communicate())
45 if len(response[0])!=0 or (str(response[1]).find("1190")!=-1):
46 return False
47 else:
48 return True
49 except :
50 return False
61def restart():
62 try:
63 with open(PID_PATH, 'r') as pid_file:
64 pid = pid_file.read()
65 except IOError:
66 pid = None
67 command = 'haproxy -f {config_path} -p {pid_path}'.format(config_path=CONFIG_PATH, pid_path=PID_PATH)
68 if pid:
69 command += ' -sf {pid}'.format(pid=pid)
70 os.system(command)
352def restart_with_reloader():
353 print 'restart with reloader:'
354 while True:
355 print ' restart tick'
356 args = [sys.executable] + ['-W%s' % o for o in sys.warnoptions] + sys.argv
357 if sys.platform == "win32":
358 args = ['"%s"' % arg for arg in args]
359 new_environ = os.environ.copy()
360 new_environ["RUN_MAIN"] = 'true'
361 exit_code = os.spawnve(os.P_WAIT, sys.executable, args, new_environ)
362 if exit_code != 3:
363 return exit_code
89@task
90def restart():
91 # on first deploy, dexter won't not be running
92 sudo("kill -HUP `cat %s/gunicorn.pid` || initctl restart dexter || (initctl stop dexter; initctl start dexter)"\
93 % (env.repo_dir))
94
95 # restart dexter-celery
96 with warn_only():
97 sudo('initctl stop dexter-celery')
98 sudo('initctl start dexter-celery')
72def restart(n=4, engines=None, **kwargs):
73 """Convenient way to restart an ipcluster."""
74 stop()
75
76 started = False
77 while not started:
78 sleep(2)
79 try:
80 start(n=n, engines=engines)
81 except RuntimeError:
82 pass
83 else:
84 started = True
212@web.route('/api/restart')
213def restart():
214 web.restart()
68def restart():
69 textedit.setText("")
70 s.write('node.restart()\n')
37def restart(self):
38 """An openbts specific command to restart the bts."""
39 delegator.run("sudo killall transceiver")
40
41 # If the pid file specified doesn't match a running instance of the
42 # process, remove the PID file. This is a workaround for a recurring
43 # OpenBTS issue we see. Note, caller must have permissions to remove file.
44 # Determine PIDs associated with pname
45 path="/var/run/OpenBTS.pid"
46 cmd = delegator.run("ps -A | grep OpenBTS")
47 if cmd.return_code != 0:
48 output = ''
49 else:
50 output = cmd.out
51 pids = []
52 for line in output.split('\n'):
53 try:
54 pids.append(int(line.strip().split()[0]))
55 except ValueError:
56 continue # not a pid, so ignore it
57 except IndexError:
58 continue # malformed, ignore
59
60 try:
61 with open(path, "r") as f:
62 pid = int(f.read().strip())
63 if pid not in pids:
64 os.remove(path)
65 except IOError as e:
66 # ignore ENOENT (pid file doesn't exist)
67 if e.errno != errno.ENOENT:
68 raise
69
70 # now restart openbts
71 Service.SupervisorService("openbts").restart()
38def restart():
39 with cd(env.tsuru_path):
40 run("tar -xzf dist.tar.gz")
41 run('circusctl restart web')
42 run('circusctl restart collector')
39def restart():
40 kill()
41 logger.warn(
42 f"[{todate(int(time.time()), '%d/%b/%Y:%H:%M:%S +0800')}]::Status(Restarting Server)")
43
44 start()

Related snippets