systemd or init.d daemon startup file
anarcat opened this issue · 6 comments
it would be nice to have a systemd .service
or init.d startup script shipped with this, to make it easier to fire up our own transit / relay servers and adress the "federation" problem (#72).
such a file could detail what permissions are necessary for wormhole to run, for example. this would then make it easier to package the server in distributions. for now, Debian ships the server code, but it doesn't startup automatically and configuration is left to the user.
Hm, I'm all for making the server easier to run, but note that the codes can only be so short because both sides are pre-configured to use the same server. So I envision non-default servers only really being useful for applications other than wormhole send
(i.e. apps which import wormhole
and use a different APPID, probably apps which are written by somebody who's maintaining their own wormhole server, so they bake in their own URLs instead of using my default).
As a result, I'm not sure whether I'd recommend packaging systemd/init.d/etc scripts. (I'd certainly not recommend packaging scripts which launch a server with the default APPID, since there's only supposed to be one server for that one).
From my point of view, it would be nice to make using a non-standard wormhole server easy from the CLI, and that involves making it easy to set up a server.
On the other hand, the systemd file for a server is so short that we could just put it into this issue here, and close it, and people would still be able to find it.
Let's definitely add a unit file. We've extracted the two servers out to separate repositories since this was first filed, so I'll move this to https://github.com/warner/magic-wormhole-mailbox-server now, but we should defintely do the same thing for https://github.com/warner/magic-wormhole-transit-relay
Any idea what a unit file for this would look like? The command to run is twist wormhole-mailbox --usage-db=.../path/to/usage.sqlite
. But of course the twist
executable has to come from an environment that has this package installed, so the command really depends upon how exactly we got installed. hmm. Maybe we should just put a skeleton of the unit file into the README, and suggest that whoever is packaging the program should fill in the details.
Oh, and one correction to my note from 2016: the mailbox server isn't limited to a single APPID.. those are provided by the clients, and the server just makes sure to only connect clients who use the same appid. So what I said about "not recommend packaging scripts which launch a server with the default APPID", ignore that, it doesn't make any sense.
i'd say assume twist
is in the path and move on. aren't there good defaults for --usage-db
? like /var/lib/wormhole/mailbox.sqlite
or something?
here's a trivial example from the irker
program:
# Copyright 2012 Wulf C. Krueger <philantrop@exherbo.org>
# Distributed under the terms of the BSD LICENSE
[Unit]
Description=Internet Relay Chat (IRC) notification daemon
Requires=network.target
Documentation=man:irkerd(8) man:irkerhook(1) man:irk(1)
[Service]
EnvironmentFile=-/etc/default/irker
ExecStart=/usr/bin/irkerd $IRKER_OPTIONS
User=irker
[Install]
WantedBy=multi-user.target
Alias=irker.service
I just set magic-worm-hole ubuntu service with:
path:/etc/systemd/system
file: magic-wormhole-server.service
[Unit]
Description=mwhserver
[Service]
ExecStart=/usr/local/bin/twistd
wormhole-mailbox
--usage-db=/tmp/usage.sqlite \
[Install]
WantedBy=multi-user.target
---reload service definition;
#sudo systemctl daemon-reload
---And check with;
#systemctl start magic-wormhole-server
#systemctl status magic-wormhole-server
● magic-wormhole-server.service - mwhserver
Loaded: loaded (/etc/systemd/system/magic-wormhole-server.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Sat 2021-10-16 15:22:35 -03; 20s ago
Process: 21773 ExecStart=/usr/local/bin/twistd wormhole-mailbox --usage-db=/tmp/usage.sqlite (code=exited, s>
Main PID: 21773 (code=exited, status=0/SUCCESS)
out 16 15:22:34 Started mwhserver.
out 16 15:22:35 magic-wormhole-server.service: Succeeded.
Now I'm to use my own wormhole server.