Update upstart scripts

This commit is contained in:
James Allen 2014-08-18 10:46:42 +01:00
parent 9e99bd835f
commit bbe5417966
11 changed files with 190 additions and 47 deletions

View file

@ -126,8 +126,10 @@ module.exports = (grunt) ->
Helpers.checkMake @async() Helpers.checkMake @async()
grunt.registerTask "check", "Check that you have the required dependencies installed", ["check:redis", "check:latexmk", "check:s3", "check:fs", "check:aspell"] grunt.registerTask "check", "Check that you have the required dependencies installed", ["check:redis", "check:latexmk", "check:s3", "check:fs", "check:aspell"]
grunt.registerTask "build_deb", "Build an installable .deb file from the current directory", () -> grunt.registerTask "build:deb", "Build an installable .deb file from the current directory", () ->
Helpers.buildDeb @async() Helpers.buildDeb @async()
grunt.registerTask "build:upstart_scripts", "Create upstart scripts for each service", () ->
Helpers.buildUpstartScripts()
Helpers = Helpers =
installService: (repo_src, dir, callback = (error) ->) -> installService: (repo_src, dir, callback = (error) ->) ->
@ -375,13 +377,18 @@ module.exports = (grunt) ->
grunt.log.write "OK." grunt.log.write "OK."
return callback() return callback()
buildUpstartScripts: () ->
template = fs.readFileSync("package/upstart/sharelatex-template").toString()
for service in SERVICES
fs.writeFileSync "package/upstart/sharelatex-#{service.name}", template.replace(/__SERVICE__/g, service.name)
buildDeb: (callback = (error) ->) -> buildDeb: (callback = (error) ->) ->
# TODO: filestore uses local 'uploads' directory, not configurable in settings # TODO: filestore uses local 'uploads' directory, not configurable in settings
command = ["-s", "dir", "-t", "deb", "-n", "sharelatex", "-v", "0.0.1", "--verbose"] command = ["-s", "dir", "-t", "deb", "-n", "sharelatex", "-v", "0.0.1", "--verbose"]
command.push( command.push(
"--maintainer", "ShareLaTeX <team@sharelatex.com>" "--maintainer", "ShareLaTeX <team@sharelatex.com>"
"--config-files", "/etc/sharelatex/settings.coffee", "--config-files", "/etc/sharelatex/settings.coffee",
"--directories", "/var/data/sharelatex" "--directories", "/var/lib/sharelatex"
"--directories", "/var/log/sharelatex" "--directories", "/var/log/sharelatex"
) )
@ -391,9 +398,8 @@ module.exports = (grunt) ->
"--depends", "nodejs > 0.10.0" "--depends", "nodejs > 0.10.0"
) )
template = fs.readFileSync("package/upstart/sharelatex-template").toString() @buildUpstartScripts()
for service in SERVICES for service in SERVICES
fs.writeFileSync "package/upstart/sharelatex-#{service.name}", template.replace(/SERVICE/g, service.name)
command.push( command.push(
"--deb-upstart", "package/upstart/sharelatex-#{service.name}" "--deb-upstart", "package/upstart/sharelatex-#{service.name}"
) )
@ -409,8 +415,8 @@ module.exports = (grunt) ->
for dir in ["user_files", "uploads", "compiles", "cache", "dump"] for dir in ["user_files", "uploads", "compiles", "cache", "dump"]
after_install_script += """ after_install_script += """
mkdir -p /var/data/sharelatex/#{dir} mkdir -p /var/lib/sharelatex/#{dir}
chown sharelatex:sharelatex /var/data/sharelatex/#{dir} chown sharelatex:sharelatex /var/lib/sharelatex/#{dir}
""" """

View file

@ -0,0 +1,27 @@
description "sharelatex-web"
author "ShareLaTeX <team@sharelatex.com>"
start on started mountall
stop on shutdown
respawn
limit nofile 8192 8192
pre-start script
mkdir -p /var/log/sharelatex
end script
script
SERVICE=chat
USER=sharelatex
GROUP=sharelatex
# You may need to replace this with an absolute
# path to Node.js if it's not in your system PATH.
NODE=node
SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee
echo $$ > /var/run/sharelatex-$SERVICE.pid
chdir /var/www/sharelatex/$SERVICE
exec sudo -u $USER -g $GROUP env SHARELATEX_CONFIG=$SHARELATEX_CONFIG NODE_ENV=production $NODE app.js >> /var/log/sharelatex/$SERVICE.log 2>&1
end script

View file

@ -1,4 +1,4 @@
description "sharelatex-clsi" description "sharelatex-web"
author "ShareLaTeX <team@sharelatex.com>" author "ShareLaTeX <team@sharelatex.com>"
start on started mountall start on started mountall
@ -9,11 +9,19 @@ respawn
limit nofile 8192 8192 limit nofile 8192 8192
pre-start script pre-start script
mkdir -p /var/log/sharelatex mkdir -p /var/log/sharelatex
end script end script
script script
echo $$ > /var/run/sharelatex-clsi.pid SERVICE=clsi
chdir /var/www/sharelatex/clsi USER=sharelatex
exec sudo -u sharelatex -g sharelatex env SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee NODE_ENV=production node app.js >> /var/log/sharelatex/clsi.log 2>&1 GROUP=sharelatex
# You may need to replace this with an absolute
# path to Node.js if it's not in your system PATH.
NODE=node
SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee
echo $$ > /var/run/sharelatex-$SERVICE.pid
chdir /var/www/sharelatex/$SERVICE
exec sudo -u $USER -g $GROUP env SHARELATEX_CONFIG=$SHARELATEX_CONFIG NODE_ENV=production $NODE app.js >> /var/log/sharelatex/$SERVICE.log 2>&1
end script end script

View file

@ -1,4 +1,4 @@
description "sharelatex-docstore" description "sharelatex-web"
author "ShareLaTeX <team@sharelatex.com>" author "ShareLaTeX <team@sharelatex.com>"
start on started mountall start on started mountall
@ -9,11 +9,19 @@ respawn
limit nofile 8192 8192 limit nofile 8192 8192
pre-start script pre-start script
mkdir -p /var/log/sharelatex mkdir -p /var/log/sharelatex
end script end script
script script
echo $$ > /var/run/sharelatex-docstore.pid SERVICE=docstore
chdir /var/www/sharelatex/docstore USER=sharelatex
exec sudo -u sharelatex -g sharelatex env SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee NODE_ENV=production node app.js >> /var/log/sharelatex/docstore.log 2>&1 GROUP=sharelatex
# You may need to replace this with an absolute
# path to Node.js if it's not in your system PATH.
NODE=node
SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee
echo $$ > /var/run/sharelatex-$SERVICE.pid
chdir /var/www/sharelatex/$SERVICE
exec sudo -u $USER -g $GROUP env SHARELATEX_CONFIG=$SHARELATEX_CONFIG NODE_ENV=production $NODE app.js >> /var/log/sharelatex/$SERVICE.log 2>&1
end script end script

View file

@ -1,4 +1,4 @@
description "sharelatex-document-updater" description "sharelatex-web"
author "ShareLaTeX <team@sharelatex.com>" author "ShareLaTeX <team@sharelatex.com>"
start on started mountall start on started mountall
@ -9,11 +9,19 @@ respawn
limit nofile 8192 8192 limit nofile 8192 8192
pre-start script pre-start script
mkdir -p /var/log/sharelatex mkdir -p /var/log/sharelatex
end script end script
script script
echo $$ > /var/run/sharelatex-document-updater.pid SERVICE=document-updater
chdir /var/www/sharelatex/document-updater USER=sharelatex
exec sudo -u sharelatex -g sharelatex env SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee NODE_ENV=production node app.js >> /var/log/sharelatex/document-updater.log 2>&1 GROUP=sharelatex
# You may need to replace this with an absolute
# path to Node.js if it's not in your system PATH.
NODE=node
SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee
echo $$ > /var/run/sharelatex-$SERVICE.pid
chdir /var/www/sharelatex/$SERVICE
exec sudo -u $USER -g $GROUP env SHARELATEX_CONFIG=$SHARELATEX_CONFIG NODE_ENV=production $NODE app.js >> /var/log/sharelatex/$SERVICE.log 2>&1
end script end script

View file

@ -1,4 +1,4 @@
description "sharelatex-filestore" description "sharelatex-web"
author "ShareLaTeX <team@sharelatex.com>" author "ShareLaTeX <team@sharelatex.com>"
start on started mountall start on started mountall
@ -9,11 +9,19 @@ respawn
limit nofile 8192 8192 limit nofile 8192 8192
pre-start script pre-start script
mkdir -p /var/log/sharelatex mkdir -p /var/log/sharelatex
end script end script
script script
echo $$ > /var/run/sharelatex-filestore.pid SERVICE=filestore
chdir /var/www/sharelatex/filestore USER=sharelatex
exec sudo -u sharelatex -g sharelatex env SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee NODE_ENV=production node app.js >> /var/log/sharelatex/filestore.log 2>&1 GROUP=sharelatex
# You may need to replace this with an absolute
# path to Node.js if it's not in your system PATH.
NODE=node
SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee
echo $$ > /var/run/sharelatex-$SERVICE.pid
chdir /var/www/sharelatex/$SERVICE
exec sudo -u $USER -g $GROUP env SHARELATEX_CONFIG=$SHARELATEX_CONFIG NODE_ENV=production $NODE app.js >> /var/log/sharelatex/$SERVICE.log 2>&1
end script end script

View file

@ -0,0 +1,27 @@
description "sharelatex-web"
author "ShareLaTeX <team@sharelatex.com>"
start on started mountall
stop on shutdown
respawn
limit nofile 8192 8192
pre-start script
mkdir -p /var/log/sharelatex
end script
script
SERVICE=spelling
USER=sharelatex
GROUP=sharelatex
# You may need to replace this with an absolute
# path to Node.js if it's not in your system PATH.
NODE=node
SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee
echo $$ > /var/run/sharelatex-$SERVICE.pid
chdir /var/www/sharelatex/$SERVICE
exec sudo -u $USER -g $GROUP env SHARELATEX_CONFIG=$SHARELATEX_CONFIG NODE_ENV=production $NODE app.js >> /var/log/sharelatex/$SERVICE.log 2>&1
end script

View file

@ -0,0 +1,27 @@
description "sharelatex-web"
author "ShareLaTeX <team@sharelatex.com>"
start on started mountall
stop on shutdown
respawn
limit nofile 8192 8192
pre-start script
mkdir -p /var/log/sharelatex
end script
script
SERVICE=tags
USER=sharelatex
GROUP=sharelatex
# You may need to replace this with an absolute
# path to Node.js if it's not in your system PATH.
NODE=node
SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee
echo $$ > /var/run/sharelatex-$SERVICE.pid
chdir /var/www/sharelatex/$SERVICE
exec sudo -u $USER -g $GROUP env SHARELATEX_CONFIG=$SHARELATEX_CONFIG NODE_ENV=production $NODE app.js >> /var/log/sharelatex/$SERVICE.log 2>&1
end script

View file

@ -1,4 +1,4 @@
description "sharelatex-SERVICE" description "sharelatex-web"
author "ShareLaTeX <team@sharelatex.com>" author "ShareLaTeX <team@sharelatex.com>"
start on started mountall start on started mountall
@ -9,11 +9,19 @@ respawn
limit nofile 8192 8192 limit nofile 8192 8192
pre-start script pre-start script
mkdir -p /var/log/sharelatex mkdir -p /var/log/sharelatex
end script end script
script script
echo $$ > /var/run/sharelatex-SERVICE.pid SERVICE=__SERVICE__
chdir /var/www/sharelatex/SERVICE USER=sharelatex
exec sudo -u sharelatex -g sharelatex env SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee NODE_ENV=production node app.js >> /var/log/sharelatex/SERVICE.log 2>&1 GROUP=sharelatex
# You may need to replace this with an absolute
# path to Node.js if it's not in your system PATH.
NODE=node
SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee
echo $$ > /var/run/sharelatex-$SERVICE.pid
chdir /var/www/sharelatex/$SERVICE
exec sudo -u $USER -g $GROUP env SHARELATEX_CONFIG=$SHARELATEX_CONFIG NODE_ENV=production $NODE app.js >> /var/log/sharelatex/$SERVICE.log 2>&1
end script end script

View file

@ -1,4 +1,4 @@
description "sharelatex-track-changes" description "sharelatex-web"
author "ShareLaTeX <team@sharelatex.com>" author "ShareLaTeX <team@sharelatex.com>"
start on started mountall start on started mountall
@ -9,11 +9,19 @@ respawn
limit nofile 8192 8192 limit nofile 8192 8192
pre-start script pre-start script
mkdir -p /var/log/sharelatex mkdir -p /var/log/sharelatex
end script end script
script script
echo $$ > /var/run/sharelatex-track-changes.pid SERVICE=track-changes
chdir /var/www/sharelatex/track-changes USER=sharelatex
exec sudo -u sharelatex -g sharelatex env SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee NODE_ENV=production node app.js >> /var/log/sharelatex/track-changes.log 2>&1 GROUP=sharelatex
# You may need to replace this with an absolute
# path to Node.js if it's not in your system PATH.
NODE=node
SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee
echo $$ > /var/run/sharelatex-$SERVICE.pid
chdir /var/www/sharelatex/$SERVICE
exec sudo -u $USER -g $GROUP env SHARELATEX_CONFIG=$SHARELATEX_CONFIG NODE_ENV=production $NODE app.js >> /var/log/sharelatex/$SERVICE.log 2>&1
end script end script

View file

@ -9,11 +9,19 @@ respawn
limit nofile 8192 8192 limit nofile 8192 8192
pre-start script pre-start script
mkdir -p /var/log/sharelatex mkdir -p /var/log/sharelatex
end script end script
script script
echo $$ > /var/run/sharelatex-web.pid SERVICE=web
chdir /var/www/sharelatex/web USER=sharelatex
exec sudo -u sharelatex -g sharelatex env SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee NODE_ENV=production node app.js >> /var/log/sharelatex/web.log 2>&1 GROUP=sharelatex
# You may need to replace this with an absolute
# path to Node.js if it's not in your system PATH.
NODE=node
SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee
echo $$ > /var/run/sharelatex-$SERVICE.pid
chdir /var/www/sharelatex/$SERVICE
exec sudo -u $USER -g $GROUP env SHARELATEX_CONFIG=$SHARELATEX_CONFIG NODE_ENV=production $NODE app.js >> /var/log/sharelatex/$SERVICE.log 2>&1
end script end script