summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/soledad-server.install1
-rw-r--r--pkg/server/soledad-server.service9
-rw-r--r--setup.py5
-rw-r--r--src/leap/soledad/server/launcher.py72
4 files changed, 78 insertions, 9 deletions
diff --git a/debian/soledad-server.install b/debian/soledad-server.install
index f3719b45..bb80e20a 100644
--- a/debian/soledad-server.install
+++ b/debian/soledad-server.install
@@ -1,3 +1,4 @@
+debian/python-leap.soledad/usr/bin/soledad-server usr/bin/
pkg/server/soledad-create-userdb usr/bin/
pkg/server/soledad-sudoers etc/sudoers.d/
src/leap/soledad/server usr/lib/python2.7/dist-packages/leap/soledad/
diff --git a/pkg/server/soledad-server.service b/pkg/server/soledad-server.service
index 0e17f245..c3331dfd 100644
--- a/pkg/server/soledad-server.service
+++ b/pkg/server/soledad-server.service
@@ -3,8 +3,6 @@ Description=Soledad Server
[Service]
Environment=PATH=/sbin:/bin:/usr/sbin:/usr/bin
-# TODO: Change this dist-packages path as it's Debian specific
-Environment=TAC=/usr/lib/python2.7/dist-packages/leap/soledad/server/server.tac
Environment=HTTPS_PORT=2424
Environment=LOCAL_SERVICES_PORT=2525
Environment=CERT_PATH=/etc/soledad/soledad-server.pem
@@ -13,12 +11,7 @@ Environment=HOME=/var/lib/soledad/
Environment=SSL_METHOD=SSLv23_METHOD
EnvironmentFile=-/etc/default/soledad
-ExecStart=/usr/bin/twistd \
- --nodaemon \
- --pidfile= \
- --syslog \
- --prefix=soledad-server \
- --python=${TAC}
+ExecStart=/usr/bin/soledad-server
WorkingDirectory=/var/lib/soledad/
diff --git a/setup.py b/setup.py
index da2ee5e3..61164b4a 100644
--- a/setup.py
+++ b/setup.py
@@ -106,6 +106,8 @@ extras = {
'signaling': signaling
}
+soledad_server = 'soledad-server=leap.soledad.server.launcher:run_server'
+
setup(
name='leap.soledad',
version=versioneer.get_version(),
@@ -129,5 +131,6 @@ setup(
package_dir={'': 'src'},
package_data={'': ["*.sql"]},
install_requires=install_requires,
- extras_require=extras
+ extras_require=extras,
+ entry_points={'console_scripts': [soledad_server]},
)
diff --git a/src/leap/soledad/server/launcher.py b/src/leap/soledad/server/launcher.py
new file mode 100644
index 00000000..d8da7083
--- /dev/null
+++ b/src/leap/soledad/server/launcher.py
@@ -0,0 +1,72 @@
+# -*- coding: utf-8 -*-
+# launcher.py
+# Copyright (C) 2017 LEAP
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+Soledad Server launcher.
+"""
+import argparse
+import os
+import sys
+
+from twisted.scripts.twistd import run
+
+from leap.soledad import server, __version__
+
+
+STANDALONE = getattr(sys, 'frozen', False)
+
+
+def parse_args():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--version', action='store_true',
+ help='Print the program version.')
+ return parser.parse_args()
+
+
+def here(module=None):
+ if STANDALONE:
+ # we are running in a |PyInstaller| bundle
+ return sys._MEIPASS
+ else:
+ if module:
+ return os.path.dirname(module.__file__)
+ else:
+ return os.path.dirname(__file__)
+
+
+def run_server():
+
+ # maybe print version and exit
+ args = parse_args()
+ if args.version:
+ print __version__
+ return
+
+ # launch soledad server using twistd
+ tac = os.path.join(here(server), 'server.tac')
+ args = [
+ '--nodaemon',
+ '--pidfile=',
+ '--syslog',
+ '--prefix=soledad-server',
+ '--python=%s' % tac,
+ ]
+ sys.argv[1:] = args
+ run()
+
+
+if __name__ == '__main__':
+ run_server()