forked from thedjpetersen/subway
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request thedjpetersen#316 from pschichtel/patch-1
Added a nginx configuration and an init script
- Loading branch information
Showing
3 changed files
with
139 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Support scripts | ||
=============== | ||
|
||
[Init Script](init.d/subway) | ||
---------------------------- | ||
|
||
This is a pretty basic init script to get subway running as a service. | ||
By default it places a log file at /var/log/subway.log and a pid file | ||
in /var/run/subway.pid . | ||
|
||
|
||
[Nginx config](nginx/subway) | ||
---------------------------- | ||
|
||
This is a simple Nginx host configuration that proxies both the normal | ||
HTTP requests as well as Websocket connections to Subway's server. | ||
Simply edit the file where necessary and throw it in your | ||
/etc/nginx/sites-enabled (or what ever it's called) folder | ||
and reload/restart your nginx (typically "service nginx reload"). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#!/bin/sh | ||
### BEGIN INIT INFO | ||
# Provides: subway | ||
# Required-Start: $local_fs $remote_fs $network $time $named | ||
# Required-Stop: $local_fs $remote_fs $network $time $named | ||
# Default-Start: 3 5 | ||
# Default-Stop: 0 1 2 6 | ||
# Short-Description: Subway Web IRC | ||
# Description: A JS based web IRC | ||
### END INIT INFO | ||
|
||
NAME="subway" | ||
SCRIPTNAME="/etc/init.d/$NAME" | ||
PREFIX="/home/znc/$NAME" | ||
USER="znc" | ||
PID="/var/run/subway.pid" | ||
LOG="/var/log/subway.log" | ||
|
||
if [ `id -u` -ne 0 ]; then | ||
echo "The $NAME init script can only be run as root" | ||
exit 1 | ||
fi | ||
|
||
SCRIPT="$PREFIX/$NAME" | ||
|
||
do_start() | ||
{ | ||
su - "$USER" -c "$SCRIPT" > "$LOG" 2>&1 & | ||
echo $! > "$PID" | ||
echo "Started: `cat "$PID"`" | ||
} | ||
|
||
do_stop() | ||
{ | ||
if [ -e "$PID" ] | ||
then | ||
kill -INT `cat "$PID"` | ||
rm "$PID" | ||
echo "Stopped" | ||
else | ||
echo "Not running." | ||
fi | ||
} | ||
|
||
do_status() | ||
{ | ||
if [ -e "$PID" ] | ||
then | ||
if kill -0 `cat "$PID"` | ||
then | ||
echo "Running: `cat $PID`" | ||
else | ||
echo "Crashed!" | ||
fi | ||
else | ||
echo "Not running." | ||
fi | ||
} | ||
|
||
do_restart() | ||
{ | ||
do_stop | ||
do_start | ||
} | ||
|
||
case "$1" in | ||
start) | ||
do_start | ||
;; | ||
stop) | ||
do_stop | ||
;; | ||
status) | ||
do_status | ||
;; | ||
restart|force-reload) | ||
do_restart | ||
;; | ||
*) | ||
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 | ||
exit 3 | ||
;; | ||
esac | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
upstream subway { | ||
server localhost:3000; | ||
} | ||
|
||
map $http_upgrade $connection_upgrade { | ||
default upgrade; | ||
'' close; | ||
} | ||
|
||
server { | ||
listen 80; | ||
# for IPv6 | ||
# listen [::]:80; | ||
server_name irc.example.org; | ||
|
||
access_log /path/to/subway/subway_access.log; | ||
error_log /path/to/subway/subway_errors.log warn; | ||
|
||
location /assets { | ||
root /path/to/subway; | ||
} | ||
|
||
location / { | ||
proxy_pass http://subway; | ||
proxy_redirect off; | ||
|
||
proxy_http_version 1.1; | ||
|
||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection $connection_upgrade; | ||
} | ||
} |