Skip to content

Commit

Permalink
working
Browse files Browse the repository at this point in the history
  • Loading branch information
lonelycode committed Oct 24, 2016
1 parent 7993e02 commit 1936dfc
Show file tree
Hide file tree
Showing 17 changed files with 559 additions and 41 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.idea/
.vagrant/
temp/
middleware/e1d21f942ec746ed416ab97fe1bf07e8/
middleware/e1d21f942ec746ed416ab97fe1bf07e8_IGNORED/
testapps/
Expand Down
18 changes: 16 additions & 2 deletions install/data/tyk.self_contained.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"enable_analytics": false,
"analytics_config": {
"type": "csv",
"pool_size": 100,
"csv_dir": "/tmp",
"mongo_url": "",
"mongo_db_name": "",
Expand Down Expand Up @@ -62,8 +63,21 @@
"http_server_options": {
"enable_websockets": true
},
"hostname": "TYK_GATEWAY_DOMAIN",
"hostname": "",
"enable_custom_domains": true,
"enable_jsvm": true,
"oauth_redirect_uri_separator": ";"
"oauth_redirect_uri_separator": ";",
"coprocess_options": {
"enable_coprocess": false,
"coprocess_grpc_server": ""
},
"pid_file_location": "./tyk-gateway.pid",
"allow_insecure_configs": true,
"public_key_path": "",
"close_idle_connections": false,
"allow_remote_config": false,
"enable_bundle_downloader": true,
"bundle_base_url": "",
"global_session_lifetime": 100,
"force_global_session_lifetime": false
}
28 changes: 23 additions & 5 deletions install/data/tyk.with_dash.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
"tyk_js_path": "/opt/tyk-gateway/js/tyk.js",
"use_db_app_configs": true,
"db_app_conf_options": {
"connection_string": "DASHBOARD_URL",
"connection_string": "",
"node_is_segmented": false,
"tags": []
},
"disable_dashboard_zeroconf": false,
"app_path": "/opt/tyk-gateway/apps",
"middleware_path": "/opt/tyk-gateway/middleware",
"storage": {
Expand All @@ -25,6 +26,7 @@
"enable_analytics": true,
"analytics_config": {
"type": "mongo",
"pool_size": 100,
"csv_dir": "/tmp",
"mongo_url": "",
"mongo_db_name": "",
Expand All @@ -49,14 +51,17 @@
"allow_master_keys": false,
"policies": {
"policy_source": "service",
"policy_connection_string": "DASHBOARD_URL",
"policy_record_name": "tyk_policies"
"policy_connection_string": "",
"policy_record_name": "tyk_policies",
"allow_explicit_policy_id": true
},
"hash_keys": true,
"suppress_redis_signal_reload": false,
"use_redis_log": true,
"close_connections": true,
"enable_non_transactional_rate_limiter": true,
"enable_sentinel_rate_limiter": false,
"experimental_process_org_off_thread": true,
"local_session_cache": {
"disable_cached_session_state": false
},
Expand All @@ -72,8 +77,21 @@
"checker_pool_size": 50
}
},
"hostname": "TYK_GATEWAY_DOMAIN",
"hostname": "",
"enable_custom_domains": true,
"enable_jsvm": true,
"oauth_redirect_uri_separator": ";"
"oauth_redirect_uri_separator": ";",
"coprocess_options": {
"enable_coprocess": false,
"coprocess_grpc_server": ""
},
"pid_file_location": "./tyk-gateway.pid",
"allow_insecure_configs": true,
"public_key_path": "",
"close_idle_connections": false,
"allow_remote_config": false,
"enable_bundle_downloader": true,
"bundle_base_url": "",
"global_session_lifetime": 100,
"force_global_session_lifetime": false
}
12 changes: 12 additions & 0 deletions install/inits/systemd/system/tyk-gateway-lua.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Tyk API Gateway (LUA Support)

[Service]
Type=simple
User=root
Group=root
ExecStart=/opt/tyk-gateway/tyk-lua --conf=/opt/tyk-gateway/tyk.conf
Restart=always

[Install]
WantedBy=multi-user.target
12 changes: 12 additions & 0 deletions install/inits/systemd/system/tyk-gateway-python.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Tyk API Gateway (Python Support)

[Service]
Type=simple
User=root
Group=root
ExecStart=/opt/tyk-gateway/tyk-python --conf=/opt/tyk-gateway/tyk.conf
Restart=always

[Install]
WantedBy=multi-user.target
6 changes: 6 additions & 0 deletions install/inits/sysv/etc/default/tyk-gateway-lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
user="root"
group="root"
chroot="/"
chdir="/"
nice=""

6 changes: 6 additions & 0 deletions install/inits/sysv/etc/default/tyk-gateway-python
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
user="root"
group="root"
chroot="/"
chdir="/"
nice=""

156 changes: 156 additions & 0 deletions install/inits/sysv/etc/init.d/tyk-gateway-lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
#!/bin/sh
# Init script for tyk-gateway
# Maintained by
# Generated by pleaserun.
# Implemented based on LSB Core 3.1:
# * Sections: 20.2, 20.3
#
### BEGIN INIT INFO
# Provides: tyk-gateway
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description:
# Description: no description given
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin
export PATH

name=tyk-gateway-lua
program=/opt/tyk-gateway/tyk-lua
args='--conf=/opt/tyk-gateway/tyk.conf'
pidfile="/var/run/$name.pid"

[ -r /etc/default/$name ] && . /etc/default/$name
[ -r /etc/sysconfig/$name ] && . /etc/sysconfig/$name

trace() {
logger -t "/etc/init.d/tyk-gateway" "$@"
}

emit() {
trace "$@"
echo "$@"
}

start() {

# Ensure the log directory is setup correctly.
[ ! -d "/var/log/" ] && mkdir "/var/log/"
chown "$user":"$group" "/var/log/"
chmod 755 "/var/log/"


# Setup any environmental stuff beforehand


# Run the program!

chroot --userspec "$user":"$group" "$chroot" sh -c "
cd \"$chdir\"
exec \"$program\" $args
" >> /var/log/tyk-gateway.stdout 2>> /var/log/tyk-gateway.stderr &

# Generate the pidfile from here. If we instead made the forked process
# generate it there will be a race condition between the pidfile writing
# and a process possibly asking for status.
echo $! > $pidfile

emit "$name started"
return 0
}

stop() {
# Try a few times to kill TERM the program
if status ; then
pid=$(cat "$pidfile")
trace "Killing $name (pid $pid) with SIGTERM"
kill -TERM $pid
# Wait for it to exit.
for i in 1 2 3 4 5 ; do
trace "Waiting $name (pid $pid) to die..."
status || break
sleep 1
done
if status ; then
emit "$name stop failed; still running."
else
emit "$name stopped."
fi
fi
}

status() {
if [ -f "$pidfile" ] ; then
pid=$(cat "$pidfile")
if ps -p $pid > /dev/null 2> /dev/null ; then
# process by this pid is running.
# It may not be our pid, but that's what you get with just pidfiles.
# TODO(sissel): Check if this process seems to be the same as the one we
# expect. It'd be nice to use flock here, but flock uses fork, not exec,
# so it makes it quite awkward to use in this case.
return 0
else
return 2 # program is dead but pid file exists
fi
else
return 3 # program is not running
fi
}

force_stop() {
if status ; then
stop
status && kill -KILL $(cat "$pidfile")
fi
}


case "$1" in
force-start|start|stop|force-stop|restart)
trace "Attempting '$1' on tyk-gateway"
;;
esac

case "$1" in
force-start)
PRESTART=no
exec "$0" start
;;
start)
status
code=$?
if [ $code -eq 0 ]; then
emit "$name is already running"
exit $code
else
start
exit $?
fi
;;
stop) stop ;;
force-stop) force_stop ;;
status)
status
code=$?
if [ $code -eq 0 ] ; then
emit "$name is running"
else
emit "$name is not running"
fi
exit $code
;;
restart)

stop && start
;;
*)
echo "Usage: $SCRIPTNAME {start|force-start|stop|force-start|force-stop|status|restart}" >&2
exit 3
;;
esac

exit $?
Loading

0 comments on commit 1936dfc

Please sign in to comment.