diff --git a/Gruntfile.coffee b/Gruntfile.coffee index f676cfbad1..35c8053a14 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -126,8 +126,10 @@ module.exports = (grunt) -> 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 "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() + grunt.registerTask "build:upstart_scripts", "Create upstart scripts for each service", () -> + Helpers.buildUpstartScripts() Helpers = installService: (repo_src, dir, callback = (error) ->) -> @@ -375,13 +377,18 @@ module.exports = (grunt) -> grunt.log.write "OK." 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) ->) -> # TODO: filestore uses local 'uploads' directory, not configurable in settings command = ["-s", "dir", "-t", "deb", "-n", "sharelatex", "-v", "0.0.1", "--verbose"] command.push( "--maintainer", "ShareLaTeX " "--config-files", "/etc/sharelatex/settings.coffee", - "--directories", "/var/data/sharelatex" + "--directories", "/var/lib/sharelatex" "--directories", "/var/log/sharelatex" ) @@ -391,9 +398,8 @@ module.exports = (grunt) -> "--depends", "nodejs > 0.10.0" ) - template = fs.readFileSync("package/upstart/sharelatex-template").toString() + @buildUpstartScripts() for service in SERVICES - fs.writeFileSync "package/upstart/sharelatex-#{service.name}", template.replace(/SERVICE/g, service.name) command.push( "--deb-upstart", "package/upstart/sharelatex-#{service.name}" ) @@ -409,8 +415,8 @@ module.exports = (grunt) -> for dir in ["user_files", "uploads", "compiles", "cache", "dump"] after_install_script += """ - mkdir -p /var/data/sharelatex/#{dir} - chown sharelatex:sharelatex /var/data/sharelatex/#{dir} + mkdir -p /var/lib/sharelatex/#{dir} + chown sharelatex:sharelatex /var/lib/sharelatex/#{dir} """ diff --git a/package/upstart/sharelatex-chat b/package/upstart/sharelatex-chat new file mode 100644 index 0000000000..869b5d82d5 --- /dev/null +++ b/package/upstart/sharelatex-chat @@ -0,0 +1,27 @@ +description "sharelatex-web" +author "ShareLaTeX " + +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 \ No newline at end of file diff --git a/package/upstart/sharelatex-clsi b/package/upstart/sharelatex-clsi index 3dfe85b14a..733ff72c44 100644 --- a/package/upstart/sharelatex-clsi +++ b/package/upstart/sharelatex-clsi @@ -1,4 +1,4 @@ -description "sharelatex-clsi" +description "sharelatex-web" author "ShareLaTeX " start on started mountall @@ -9,11 +9,19 @@ respawn limit nofile 8192 8192 pre-start script - mkdir -p /var/log/sharelatex + mkdir -p /var/log/sharelatex end script script - echo $$ > /var/run/sharelatex-clsi.pid - chdir /var/www/sharelatex/clsi - 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 -end script + SERVICE=clsi + 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 \ No newline at end of file diff --git a/package/upstart/sharelatex-docstore b/package/upstart/sharelatex-docstore index 542fe550ad..0bf1ad3c1e 100644 --- a/package/upstart/sharelatex-docstore +++ b/package/upstart/sharelatex-docstore @@ -1,4 +1,4 @@ -description "sharelatex-docstore" +description "sharelatex-web" author "ShareLaTeX " start on started mountall @@ -9,11 +9,19 @@ respawn limit nofile 8192 8192 pre-start script - mkdir -p /var/log/sharelatex + mkdir -p /var/log/sharelatex end script script - echo $$ > /var/run/sharelatex-docstore.pid - chdir /var/www/sharelatex/docstore - 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 -end script + SERVICE=docstore + 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 \ No newline at end of file diff --git a/package/upstart/sharelatex-document-updater b/package/upstart/sharelatex-document-updater index ef31136031..71e7ef2d83 100644 --- a/package/upstart/sharelatex-document-updater +++ b/package/upstart/sharelatex-document-updater @@ -1,4 +1,4 @@ -description "sharelatex-document-updater" +description "sharelatex-web" author "ShareLaTeX " start on started mountall @@ -9,11 +9,19 @@ respawn limit nofile 8192 8192 pre-start script - mkdir -p /var/log/sharelatex + mkdir -p /var/log/sharelatex end script script - echo $$ > /var/run/sharelatex-document-updater.pid - chdir /var/www/sharelatex/document-updater - 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 -end script + SERVICE=document-updater + 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 \ No newline at end of file diff --git a/package/upstart/sharelatex-filestore b/package/upstart/sharelatex-filestore index 6f5c73bc4f..31a637ba45 100644 --- a/package/upstart/sharelatex-filestore +++ b/package/upstart/sharelatex-filestore @@ -1,4 +1,4 @@ -description "sharelatex-filestore" +description "sharelatex-web" author "ShareLaTeX " start on started mountall @@ -9,11 +9,19 @@ respawn limit nofile 8192 8192 pre-start script - mkdir -p /var/log/sharelatex + mkdir -p /var/log/sharelatex end script script - echo $$ > /var/run/sharelatex-filestore.pid - chdir /var/www/sharelatex/filestore - 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 -end script + SERVICE=filestore + 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 \ No newline at end of file diff --git a/package/upstart/sharelatex-spelling b/package/upstart/sharelatex-spelling new file mode 100644 index 0000000000..4e2c3ed80e --- /dev/null +++ b/package/upstart/sharelatex-spelling @@ -0,0 +1,27 @@ +description "sharelatex-web" +author "ShareLaTeX " + +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 \ No newline at end of file diff --git a/package/upstart/sharelatex-tags b/package/upstart/sharelatex-tags new file mode 100644 index 0000000000..0a4a47af5b --- /dev/null +++ b/package/upstart/sharelatex-tags @@ -0,0 +1,27 @@ +description "sharelatex-web" +author "ShareLaTeX " + +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 \ No newline at end of file diff --git a/package/upstart/sharelatex-template b/package/upstart/sharelatex-template index f9ed4c6a93..15a0e37683 100644 --- a/package/upstart/sharelatex-template +++ b/package/upstart/sharelatex-template @@ -1,4 +1,4 @@ -description "sharelatex-SERVICE" +description "sharelatex-web" author "ShareLaTeX " start on started mountall @@ -9,11 +9,19 @@ respawn limit nofile 8192 8192 pre-start script - mkdir -p /var/log/sharelatex + mkdir -p /var/log/sharelatex end script script - echo $$ > /var/run/sharelatex-SERVICE.pid - chdir /var/www/sharelatex/SERVICE - 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 -end script + SERVICE=__SERVICE__ + 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 \ No newline at end of file diff --git a/package/upstart/sharelatex-track-changes b/package/upstart/sharelatex-track-changes index 2b3b61dfd1..1454819aaa 100644 --- a/package/upstart/sharelatex-track-changes +++ b/package/upstart/sharelatex-track-changes @@ -1,4 +1,4 @@ -description "sharelatex-track-changes" +description "sharelatex-web" author "ShareLaTeX " start on started mountall @@ -9,11 +9,19 @@ respawn limit nofile 8192 8192 pre-start script - mkdir -p /var/log/sharelatex + mkdir -p /var/log/sharelatex end script script - echo $$ > /var/run/sharelatex-track-changes.pid - chdir /var/www/sharelatex/track-changes - 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 -end script + SERVICE=track-changes + 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 \ No newline at end of file diff --git a/package/upstart/sharelatex-web b/package/upstart/sharelatex-web index 86d83bba78..f18e751b70 100644 --- a/package/upstart/sharelatex-web +++ b/package/upstart/sharelatex-web @@ -9,11 +9,19 @@ respawn limit nofile 8192 8192 pre-start script - mkdir -p /var/log/sharelatex + mkdir -p /var/log/sharelatex end script script - echo $$ > /var/run/sharelatex-web.pid - chdir /var/www/sharelatex/web - 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 -end script + SERVICE=web + 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 \ No newline at end of file