From ece429d9b0723f07b215c69f900e055b619fafad Mon Sep 17 00:00:00 2001 From: Miguel Serrano Date: Tue, 10 Sep 2019 17:13:17 +0200 Subject: [PATCH] Added debugging support to services (#113) --- .dockerignore | 2 +- Dockerfile-base | 2 +- runit/chat-sharelatex/run | 9 ++++++++- runit/clsi-sharelatex/run | 9 ++++++++- runit/contacts-sharelatex/run | 9 ++++++++- runit/docstore-sharelatex/run | 9 ++++++++- runit/document-updater-sharelatex/run | 9 ++++++++- runit/notifications-sharelatex/run | 9 ++++++++- runit/real-time-sharelatex/run | 2 +- runit/spelling-sharelatex/run | 9 ++++++++- runit/tags-sharelatex/run | 9 ++++++++- runit/track-changes-sharelatex/run | 9 ++++++++- runit/web-sharelatex/run | 9 ++++++++- settings.coffee | 28 +++++++++++++-------------- 14 files changed, 97 insertions(+), 27 deletions(-) diff --git a/.dockerignore b/.dockerignore index fd3df9c73e..2a5c59398a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,3 @@ .DS_Store .git/ -node_modules/ \ No newline at end of file +node_modules/ diff --git a/Dockerfile-base b/Dockerfile-base index f56136fd87..2cff8a830f 100644 --- a/Dockerfile-base +++ b/Dockerfile-base @@ -43,7 +43,7 @@ RUN wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz && \ mkdir /install-tl-unx && \ tar -xvf install-tl-unx.tar.gz -C /install-tl-unx --strip-components=1 RUN echo "selected_scheme scheme-basic" >> /install-tl-unx/texlive.profile && \ - /install-tl-unx/install-tl -profile /install-tl-unx/texlive.profile + /install-tl-unx/install-tl -profile /install-tl-unx/texlive.profile # CTAN mirrors occasionally fail, in that case install TexLive against an # specific server, for example http://ctan.crest.fr diff --git a/runit/chat-sharelatex/run b/runit/chat-sharelatex/run index 1b8533bb86..cc5f75057f 100755 --- a/runit/chat-sharelatex/run +++ b/runit/chat-sharelatex/run @@ -1,3 +1,10 @@ #!/bin/bash export SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee -exec /sbin/setuser www-data /usr/bin/node /var/www/sharelatex/chat/app.js >> /var/log/sharelatex/chat.log 2>&1 \ No newline at end of file + +NODE_PARAMS="" +if [ "$DEBUG_NODE" == "true" ]; then + echo "running debug - chat" + NODE_PARAMS="--inspect=0.0.0.0:30100" +fi + +exec /sbin/setuser www-data /usr/bin/node $NODE_PARAMS /var/www/sharelatex/chat/app.js >> /var/log/sharelatex/chat.log 2>&1 diff --git a/runit/clsi-sharelatex/run b/runit/clsi-sharelatex/run index 1c6974cd2a..7492acf6d1 100755 --- a/runit/clsi-sharelatex/run +++ b/runit/clsi-sharelatex/run @@ -1,3 +1,10 @@ #!/bin/bash export SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee -exec /sbin/setuser www-data /usr/bin/node /var/www/sharelatex/clsi/app.js >> /var/log/sharelatex/clsi.log 2>&1 \ No newline at end of file + +NODE_PARAMS="" +if [ "$DEBUG_NODE" == "true" ]; then + echo "running debug - clsi" + NODE_PARAMS="--inspect=0.0.0.0:30130" +fi + +exec /sbin/setuser www-data /usr/bin/node $NODE_PARAMS /var/www/sharelatex/clsi/app.js >> /var/log/sharelatex/clsi.log 2>&1 diff --git a/runit/contacts-sharelatex/run b/runit/contacts-sharelatex/run index 29b513cb97..e220d9ac1d 100755 --- a/runit/contacts-sharelatex/run +++ b/runit/contacts-sharelatex/run @@ -1,3 +1,10 @@ #!/bin/bash export SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee -exec /sbin/setuser www-data /usr/bin/node /var/www/sharelatex/contacts/app.js >> /var/log/sharelatex/contacts 2>&1 + +NODE_PARAMS="" +if [ "$DEBUG_NODE" == "true" ]; then + echo "running debug - contacts" + NODE_PARAMS="--inspect=0.0.0.0:30360" +fi + +exec /sbin/setuser www-data /usr/bin/node $NODE_PARAMS /var/www/sharelatex/contacts/app.js >> /var/log/sharelatex/contacts 2>&1 diff --git a/runit/docstore-sharelatex/run b/runit/docstore-sharelatex/run index 0de82ccf20..2a171f0968 100755 --- a/runit/docstore-sharelatex/run +++ b/runit/docstore-sharelatex/run @@ -1,3 +1,10 @@ #!/bin/bash export SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee -exec /sbin/setuser www-data /usr/bin/node /var/www/sharelatex/docstore/app.js >> /var/log/sharelatex/docstore.log 2>&1 \ No newline at end of file + +NODE_PARAMS="" +if [ "$DEBUG_NODE" == "true" ]; then + echo "running debug - docstore" + NODE_PARAMS="--inspect=0.0.0.0:30160" +fi + +exec /sbin/setuser www-data /usr/bin/node $NODE_PARAMS /var/www/sharelatex/docstore/app.js >> /var/log/sharelatex/docstore.log 2>&1 diff --git a/runit/document-updater-sharelatex/run b/runit/document-updater-sharelatex/run index 274b7f9998..51472b3d48 100755 --- a/runit/document-updater-sharelatex/run +++ b/runit/document-updater-sharelatex/run @@ -1,3 +1,10 @@ #!/bin/bash export SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee -exec /sbin/setuser www-data /usr/bin/node /var/www/sharelatex/document-updater/app.js >> /var/log/sharelatex/document-updater.log 2>&1 \ No newline at end of file + +NODE_PARAMS="" +if [ "$DEBUG_NODE" == "true" ]; then + echo "running debug - document updater" + NODE_PARAMS="--inspect=0.0.0.0:30030" +fi + +exec /sbin/setuser www-data /usr/bin/node $NODE_PARAMS /var/www/sharelatex/document-updater/app.js >> /var/log/sharelatex/document-updater.log 2>&1 diff --git a/runit/notifications-sharelatex/run b/runit/notifications-sharelatex/run index 12b3457f2c..89f8ad54f9 100755 --- a/runit/notifications-sharelatex/run +++ b/runit/notifications-sharelatex/run @@ -1,3 +1,10 @@ #!/bin/bash export SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee -exec /sbin/setuser www-data /usr/bin/node /var/www/sharelatex/notifications/app.js >> /var/log/sharelatex/notifications.log 2>&1 \ No newline at end of file + +NODE_PARAMS="" +if [ "$DEBUG_NODE" == "true" ]; then + echo "running debug - notifications" + NODE_PARAMS="--inspect=0.0.0.0:30420" +fi + +exec /sbin/setuser www-data /usr/bin/node $NODE_PARAMS /var/www/sharelatex/notifications/app.js >> /var/log/sharelatex/notifications.log 2>&1 diff --git a/runit/real-time-sharelatex/run b/runit/real-time-sharelatex/run index 7168368c38..1d00837def 100755 --- a/runit/real-time-sharelatex/run +++ b/runit/real-time-sharelatex/run @@ -1,3 +1,3 @@ #!/bin/bash export SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee -exec /sbin/setuser www-data /usr/bin/node6 /var/www/sharelatex/real-time/app.js >> /var/log/sharelatex/real-time.log 2>&1 \ No newline at end of file +exec /sbin/setuser www-data /usr/bin/node6 /var/www/sharelatex/real-time/app.js >> /var/log/sharelatex/real-time.log 2>&1 diff --git a/runit/spelling-sharelatex/run b/runit/spelling-sharelatex/run index 4466bcfcf5..a9a73f8ae0 100755 --- a/runit/spelling-sharelatex/run +++ b/runit/spelling-sharelatex/run @@ -1,3 +1,10 @@ #!/bin/bash export SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee -exec /sbin/setuser www-data /usr/bin/node /var/www/sharelatex/spelling/app.js >> /var/log/sharelatex/spelling.log 2>&1 \ No newline at end of file + +NODE_PARAMS="" +if [ "$DEBUG_NODE" == "true" ]; then + echo "running debug - spelling" + NODE_PARAMS="--inspect=0.0.0.0:30050" +fi + +exec /sbin/setuser www-data /usr/bin/node $NODE_PARAMS /var/www/sharelatex/spelling/app.js >> /var/log/sharelatex/spelling.log 2>&1 diff --git a/runit/tags-sharelatex/run b/runit/tags-sharelatex/run index a5630ed4ff..62fe058ad9 100755 --- a/runit/tags-sharelatex/run +++ b/runit/tags-sharelatex/run @@ -1,3 +1,10 @@ #!/bin/bash export SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee -exec /sbin/setuser www-data /usr/bin/node /var/www/sharelatex/tags/app.js >> /var/log/sharelatex/tags.log 2>&1 \ No newline at end of file + +NODE_PARAMS="" +if [ "$DEBUG_NODE" == "true" ]; then + echo "running debug - tags" + NODE_PARAMS="--inspect=0.0.0.0:30120" +fi + +exec /sbin/setuser www-data /usr/bin/node $NODE_PARAMS /var/www/sharelatex/tags/app.js >> /var/log/sharelatex/tags.log 2>&1 diff --git a/runit/track-changes-sharelatex/run b/runit/track-changes-sharelatex/run index aeb812ef38..45b3b77ebc 100755 --- a/runit/track-changes-sharelatex/run +++ b/runit/track-changes-sharelatex/run @@ -1,3 +1,10 @@ #!/bin/bash export SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee -exec /sbin/setuser www-data /usr/bin/node /var/www/sharelatex/track-changes/app.js >> /var/log/sharelatex/track-changes.log 2>&1 \ No newline at end of file + +NODE_PARAMS="" +if [ "$DEBUG_NODE" == "true" ]; then + echo "running debug - track-changes" + NODE_PARAMS="--inspect=0.0.0.0:30150" +fi + +exec /sbin/setuser www-data /usr/bin/node $NODE_PARAMS /var/www/sharelatex/track-changes/app.js >> /var/log/sharelatex/track-changes.log 2>&1 diff --git a/runit/web-sharelatex/run b/runit/web-sharelatex/run index 053a55a326..c1371de0f4 100755 --- a/runit/web-sharelatex/run +++ b/runit/web-sharelatex/run @@ -1,3 +1,10 @@ #!/bin/bash export SHARELATEX_CONFIG=/etc/sharelatex/settings.coffee -exec /sbin/setuser www-data /usr/bin/node /var/www/sharelatex/web/app.js >> /var/log/sharelatex/web.log 2>&1 \ No newline at end of file + +NODE_PARAMS="" +if [ "$DEBUG_NODE" == "true" ]; then + echo "running debug - web" + NODE_PARAMS="--inspect=0.0.0.0:40000" +fi + +exec /sbin/setuser www-data /usr/bin/node $NODE_PARAMS /var/www/sharelatex/web/app.js >> /var/log/sharelatex/web.log 2>&1 diff --git a/settings.coffee b/settings.coffee index fb930628a1..3cb6a510b9 100644 --- a/settings.coffee +++ b/settings.coffee @@ -34,7 +34,7 @@ settings = # Documentation about the URL connection string format can be found at: # # http://docs.mongodb.org/manual/reference/connection-string/ - # + # # The following works out of the box with Mongo's default settings: mongo: url : process.env["SHARELATEX_MONGO_URL"] or 'mongodb://dockerhost/sharelatex' @@ -105,11 +105,11 @@ settings = # ShareLaTeX can store binary files like images either locally or in Amazon # S3. The default is locally: filestore: - backend: "fs" + backend: "fs" stores: user_files: Path.join(DATA_DIR, "user_files") template_files: Path.join(DATA_DIR, "template_files") - + # To use Amazon S3 as a storage backend, comment out the above config, and # uncomment the following, filling in your key, secret, and bucket name: # @@ -120,7 +120,7 @@ settings = # s3: # key: "AWS_KEY" # secret: "AWS_SECRET" - # + # trackchanges: continueOnError: true @@ -158,7 +158,7 @@ settings = # The email address which users will be directed to as the main point of # contact for this installation of ShareLaTeX. adminEmail: process.env["SHARELATEX_ADMIN_EMAIL"] or "placeholder@example.com" - + # If provided, a sessionSecret is used to sign cookies so that they cannot be # spoofed. This is recommended. security: @@ -167,7 +167,7 @@ settings = # These credentials are used for authenticating api requests # between services that may need to go over public channels httpAuthUsers: httpAuthUsers - + # Should javascript assets be served minified or not. useMinifiedJs: true @@ -179,7 +179,7 @@ settings = # If you are running ShareLaTeX over https, set this to true to send the # cookie with a secure flag (recommended). secureCookie: process.env["SHARELATEX_SECURE_COOKIE"]? - + # If you are running ShareLaTeX behind a proxy (like Apache, Nginx, etc) # then set this to true to allow it to correctly detect the forwarded IP # address and http/https protocol information. @@ -197,9 +197,9 @@ settings = user: httpAuthUser pass: httpAuthPass # overrides v1.url to indicate via Feature Flags that Overleaf V1 - # is not available + # is not available v1: - url: "" + url: "" references:{} notifications:undefined @@ -260,7 +260,7 @@ if process.env["SHARELATEX_HEADER_EXTRAS"]? if process.env["SHARELATEX_EMAIL_FROM_ADDRESS"]? - + settings.email = fromAddress: process.env["SHARELATEX_EMAIL_FROM_ADDRESS"] replyTo: process.env["SHARELATEX_EMAIL_REPLY_TO"] or "" @@ -291,7 +291,7 @@ if process.env["SHARELATEX_EMAIL_FROM_ADDRESS"]? # i18n -if process.env["SHARELATEX_LANG_DOMAIN_MAPPING"]? +if process.env["SHARELATEX_LANG_DOMAIN_MAPPING"]? settings.i18n.subdomainLang = parse(process.env["SHARELATEX_LANG_DOMAIN_MAPPING"]) @@ -484,7 +484,7 @@ if process.env["SHARELATEX_SAML_ENTRYPOINT"] ) # SHARELATEX_SAML_CERT cannot be empty - # https://github.com/bergie/passport-saml/commit/f6b1c885c0717f1083c664345556b535f217c102 + # https://github.com/bergie/passport-saml/commit/f6b1c885c0717f1083c664345556b535f217c102 if process.env["SHARELATEX_SAML_CERT"] settings.saml.server.cert = process.env["SHARELATEX_SAML_CERT"] settings.saml.server.privateCert = process.env["SHARELATEX_SAML_PRIVATE_CERT"] @@ -518,7 +518,7 @@ if process.env["SHARELATEX_TEMPLATES_USER_ID"] settings.templates = mountPointUrl: "/templates" user_id: process.env["SHARELATEX_TEMPLATES_USER_ID"] - + settings.templateLinks = parse(process.env["SHARELATEX_NEW_PROJECT_TEMPLATE_LINKS"]) @@ -533,7 +533,7 @@ if process.env["SHARELATEX_PROXY_LEARN"]? if process.env["SHARELATEX_ELASTICSEARCH_URL"]? settings.references.elasticsearch = host: process.env["SHARELATEX_ELASTICSEARCH_URL"] - + # With lots of incoming and outgoing HTTP connections to different services, # sometimes long running, it is a good idea to increase the default number