mirror of https://github.com/jumpserver/jumpserver
change(service.sh, run_websocket) 修改启动脚本, rename run_websocket.py
1. 修改启动脚本,支持放到 init.d 2. rename run_websocket.py -> run_server.py 交互式启动pull/97/head
commit
532fbbd4f1
|
@ -2,6 +2,8 @@
|
||||||
url = http://192.168.244.129
|
url = http://192.168.244.129
|
||||||
websocket_url = ws://192.168.244.129
|
websocket_url = ws://192.168.244.129
|
||||||
key = 88aaaf7ffe3c6c04
|
key = 88aaaf7ffe3c6c04
|
||||||
|
ip = 127.0.0.1
|
||||||
|
port = 8080
|
||||||
log = debug
|
log = debug
|
||||||
|
|
||||||
[db]
|
[db]
|
||||||
|
|
|
@ -42,6 +42,8 @@ KEY = config.get('base', 'key')
|
||||||
URL = config.get('base', 'url')
|
URL = config.get('base', 'url')
|
||||||
LOG_LEVEL = config.get('base', 'log')
|
LOG_LEVEL = config.get('base', 'log')
|
||||||
WEB_SOCKET_URL = config.get('base', 'websocket_url')
|
WEB_SOCKET_URL = config.get('base', 'websocket_url')
|
||||||
|
IP = config.get('base', 'ip')
|
||||||
|
PORT = config.get('base', 'port')
|
||||||
|
|
||||||
# Quick-start development settings - unsuitable for production
|
# Quick-start development settings - unsuitable for production
|
||||||
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
|
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
|
||||||
|
|
|
@ -33,8 +33,9 @@ except ImportError:
|
||||||
import json
|
import json
|
||||||
|
|
||||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'jumpserver.settings'
|
os.environ['DJANGO_SETTINGS_MODULE'] = 'jumpserver.settings'
|
||||||
define("port", default=3000, help="run on the given port", type=int)
|
from jumpserver.settings import IP, PORT
|
||||||
define("host", default='0.0.0.0', help="run port on given host", type=str)
|
define("port", default=PORT, help="run on the given port", type=int)
|
||||||
|
define("host", default=IP, help="run port on given host", type=str)
|
||||||
|
|
||||||
|
|
||||||
def require_auth(role='user'):
|
def require_auth(role='user'):
|
||||||
|
@ -317,6 +318,8 @@ class WebTerminalHandler(tornado.websocket.WebSocketHandler):
|
||||||
self.term = WebTty(self.user, asset, login_role, login_type='web')
|
self.term = WebTty(self.user, asset, login_role, login_type='web')
|
||||||
# self.term.remote_ip = self.request.remote_ip
|
# self.term.remote_ip = self.request.remote_ip
|
||||||
self.term.remote_ip = self.request.headers.get("X-Real-IP")
|
self.term.remote_ip = self.request.headers.get("X-Real-IP")
|
||||||
|
if not self.term.remote_ip:
|
||||||
|
self.term.remote_ip = self.request.remote_ip
|
||||||
self.ssh = self.term.get_connection()
|
self.ssh = self.term.get_connection()
|
||||||
self.channel = self.ssh.invoke_shell(term='xterm')
|
self.channel = self.ssh.invoke_shell(term='xterm')
|
||||||
WebTerminalHandler.tasks.append(MyThread(target=self.forward_outbound))
|
WebTerminalHandler.tasks.append(MyThread(target=self.forward_outbound))
|
||||||
|
@ -461,6 +464,6 @@ if __name__ == '__main__':
|
||||||
# server.bind(options.port, options.host)
|
# server.bind(options.port, options.host)
|
||||||
# #server.listen(options.port)
|
# #server.listen(options.port)
|
||||||
# server.start(num_processes=5)
|
# server.start(num_processes=5)
|
||||||
# print "Run server on %s:%s" % (options.host, options.port)
|
|
||||||
# tornado.ioloop.IOLoop.instance().start()
|
# tornado.ioloop.IOLoop.instance().start()
|
||||||
|
print "Run server on %s:%s" % (options.host, options.port)
|
||||||
main()
|
main()
|
82
service.sh
82
service.sh
|
@ -4,53 +4,43 @@
|
||||||
# chkconfig: - 85 12
|
# chkconfig: - 85 12
|
||||||
# description: Open source detecting system
|
# description: Open source detecting system
|
||||||
# processname: jumpserver
|
# processname: jumpserver
|
||||||
# Date: 2015-04-12
|
# Date: 2016-02-27
|
||||||
# Version: 2.0.0
|
# Version: 3.0.1
|
||||||
# Site: http://www.jumpserver.org
|
# Site: http://www.jumpserver.org
|
||||||
# Author: Jumpserver Team
|
# Author: Jumpserver Team
|
||||||
|
|
||||||
|
jumpserver_dir=
|
||||||
|
|
||||||
base_dir=$(dirname $0)
|
base_dir=$(dirname $0)
|
||||||
|
jumpserver_dir=${jumpserver_dir:-$base_dir}
|
||||||
|
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||||
|
|
||||||
. ${base_dir}/functions
|
if [ -f ${jumpserver_dir}/install/functions ];then
|
||||||
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/node/bin
|
. ${jumpserver_dir}/install/functions
|
||||||
|
elif [ -f /etc/init.d/functions ];then
|
||||||
|
. /etc/init.d/functions
|
||||||
|
else
|
||||||
|
echo "No functions script found in [./functions, ./install/functions, /etc/init.d/functions]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
PROC_NAME="jumpserver"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PROC_NAME="jumpsever"
|
|
||||||
lockfile=/var/lock/subsys/${PROC_NAME}
|
lockfile=/var/lock/subsys/${PROC_NAME}
|
||||||
|
|
||||||
|
|
||||||
start() {
|
start() {
|
||||||
jump_start=$"Starting ${PROC_NAME} service:"
|
jump_start=$"Starting ${PROC_NAME} service:"
|
||||||
|
|
||||||
if [ -f $lockfile ];then
|
if [ -f $lockfile ];then
|
||||||
echo "jumpserver is running..."
|
echo -n "jumpserver is running..."
|
||||||
success "$jump_start"
|
success "$jump_start"
|
||||||
|
echo
|
||||||
else
|
else
|
||||||
daemon python $base_dir/manage.py runserver 0.0.0.0:80 &>> /tmp/jumpserver.log 2>&1 &
|
daemon python $jumpserver_dir/manage.py crontab add &>> /var/log/jumpserver.log 2>&1
|
||||||
daemon python $base_dir/manage.py crontab add &>> /tmp/jumpserver.log 2>&1
|
daemon python $jumpserver_dir/run_server.py &> /dev/null 2>&1 &
|
||||||
daemon python $base_dir/run_websocket.py &> /dev/null 2>&1 &
|
sleep 1
|
||||||
sleep 4
|
|
||||||
|
|
||||||
echo -n "$jump_start"
|
echo -n "$jump_start"
|
||||||
nums=0
|
ps axu | grep 'run_server' | grep -v 'grep' &> /dev/null
|
||||||
for i in manage.py run_websocket.py;do
|
if [ $? == '0' ];then
|
||||||
if ps aux | grep "$i" | grep -v 'grep' &> /dev/null; then
|
|
||||||
nums=$[nums+1]
|
|
||||||
else
|
|
||||||
echo "$i not running"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [ "x$nums" == "x2" ];then
|
|
||||||
success "$jump_start"
|
success "$jump_start"
|
||||||
if [ ! -e $lockfile ]; then
|
|
||||||
lockfile_dir=`dirname $lockfile`
|
|
||||||
mkdir -pv $lockfile_dir
|
|
||||||
fi
|
|
||||||
touch "$lockfile"
|
touch "$lockfile"
|
||||||
echo
|
echo
|
||||||
else
|
else
|
||||||
|
@ -58,19 +48,14 @@ start() {
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
|
|
||||||
echo -n $"Stopping ${PROC_NAME} service:"
|
echo -n $"Stopping ${PROC_NAME} service:"
|
||||||
|
daemon python $jumpserver_dir/manage.py crontab remove &>> /var/log/jumpserver.log 2>&1
|
||||||
daemon python $base_dir/manage.py crontab remove &>> /tmp/jumpserver.log 2>&1
|
ps aux | grep -E 'run_server.py' | grep -v grep | awk '{print $2}' | xargs kill -9 &> /dev/null
|
||||||
ps aux | grep -E 'manage.py|run_websocket.py' | grep -v grep | awk '{print $2}' | xargs kill -9 &> /dev/null
|
|
||||||
ret=$?
|
ret=$?
|
||||||
|
|
||||||
if [ $ret -eq 0 ]; then
|
if [ $ret -eq 0 ]; then
|
||||||
echo_success
|
echo_success
|
||||||
echo
|
echo
|
||||||
|
@ -83,6 +68,20 @@ stop() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
status(){
|
||||||
|
ps axu | grep 'run_server' | grep -v 'grep' &> /dev/null
|
||||||
|
if [ $? == '0' ];then
|
||||||
|
echo -n "jumpserver is running..."
|
||||||
|
success
|
||||||
|
touch "$lockfile"
|
||||||
|
echo
|
||||||
|
else
|
||||||
|
echo -n "jumpserver is not running."
|
||||||
|
failure
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
restart(){
|
restart(){
|
||||||
|
@ -103,7 +102,10 @@ case "$1" in
|
||||||
restart
|
restart
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
status)
|
||||||
|
status
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo $"Usage: $0 {start|stop|restart}"
|
echo $"Usage: $0 {start|stop|restart|status}"
|
||||||
exit 2
|
exit 2
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in New Issue