Skip to content

Commit

Permalink
Upstart script.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwigway committed Nov 19, 2014
1 parent c3f6fa0 commit 9180b1f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions init/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This folder contains init scripts to start the editor. By default they assume an installation in
`/opt/gtfs-editor` and a user gtfs-editor to run the editor; feel free to edit as needed.

Note that whatever user you choose must be able to write to teh log and pid server files.
32 changes: 32 additions & 0 deletions init/gtfs-editor.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Upstart script to start GTFS Editor

env user=matthewc
# configure port and bind address in application.cong

# application home directory
chdir /home/matthewc/conveyal/gtfs-editor

start on runlevel [3]

pre-start script
# We set up an exclusive temporary directory so that Geotools will play nice with other Geotools apps on the system,
# which may be running as different users
# see http://www.indicatrix.org/2014/10/20/using-geotools-with-multiple-user-accounts/

# The environment stuff with writing to a file is a bit annoying; see http://stackoverflow.com/questions/12610335
TMPDIR=`mktemp -d`
chown $user $TMPDIR
echo "TMPDIR=$TMPDIR" > "/tmp/$UPSTART_JOB"
end script

script
. "/tmp/$UPSTART_JOB"
su -m -c "exec play run --%production" $user
end script

post-stop script
# Clear out our temporary directory
. "/tmp/$UPSTART_JOB"
rm -rf "$TMPDIR"
rm "/tmp/$UPSTART_JOB"
end script

0 comments on commit 9180b1f

Please sign in to comment.