Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ATLAS-651] Add atlas_status.py script #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions distro/src/bin/atlas_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/usr/bin/env python

#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
from signal import SIGTERM
import sys
import traceback

import atlas_config as mc

def main():

atlas_home = mc.atlasDir()
confdir = mc.dirMustExist(mc.confDir(atlas_home))
mc.executeEnvSh(confdir)
piddir = mc.dirMustExist(mc.logDir(atlas_home))

atlas_pid_file = mc.pidFile(atlas_home)

try:
pf = file(atlas_pid_file, 'r')
pid = int(pf.read().strip())
pf.close()
except:
pid = None
if not pid:
sys.stdout.write("Server is not running (no PID file found)\n")
return
if mc.ON_POSIX:

if not mc.unix_exist_pid(pid):
sys.stdout.write("Server is not running (%s not used anymore)\n" %pid)
return
else:
if mc.IS_WINDOWS:
if not mc.win_exist_pid((str)(pid)):
sys.stdout.write("Server is not running (%s not used anymore)\n" %pid)
return

sys.stdout.write("Server is running (%s)\n" %pid)

if __name__ == '__main__':
try:
returncode = main()
except Exception as e:
print "Exception: %s " % str(e)
print traceback.format_exc()
returncode = -1

sys.exit(returncode)