Specify full path to appscale-stop-instance
In Trusty, /usr/local/bin is not on the path under monit even when
starting under bash.
@@ -47,11 +47,19 @@ def create_config_file(watch, start_cmd, pidfile, port=None, env_vars=None,
bash = find_executable('bash')
start_stop_daemon = find_executable('start-stop-daemon')
+ stop_instance = find_executable('appscale-stop-instance')
+
+ # /usr/local/bin is not on the path in Trusty.
+ stop_instance_script = os.path.join('/', 'usr', 'local', 'bin',
+ 'appscale-stop-instance')
+ if stop_instance is None and os.path.isfile(stop_instance_script):
+ stop_instance = stop_instance_script
+
+ assert stop_instance is not None, 'Unable to find appscale-stop-instance'
logfile = os.path.join(
'/', 'var', 'log', 'appscale', '{}.log'.format(process_name))
- stop = 'appscale-stop-instance --watch {}'.format(process_name)
if syslog_server is None:
bash_exec = 'exec env {vars} {start_cmd} >> {log} 2>&1'.format(
vars=env_vars_str, start_cmd=start_cmd, log=logfile)
@@ -69,7 +77,7 @@ def create_config_file(watch, start_cmd, pidfile, port=None, env_vars=None,
'--pidfile', pidfile,
'--startas', "{} -- -c '{}'".format(bash, bash_exec)
])
- stop_line = "{} -c '{}'".format(bash, stop)
+ stop_line = '{} --watch {}'.format(stop_instance, process_name)
with open(TEMPLATE_LOCATION) as template:
output = template.read()
