summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/cron5
-rw-r--r--examples/docker/email-transport.sh5
-rw-r--r--examples/docker/travelynx.conf26
-rw-r--r--examples/nginx/travelynx.conf40
-rw-r--r--examples/travelynx.conf135
-rw-r--r--examples/travelynx.service10
6 files changed, 181 insertions, 40 deletions
diff --git a/examples/cron b/examples/cron
new file mode 100644
index 0000000..92b4faf
--- /dev/null
+++ b/examples/cron
@@ -0,0 +1,5 @@
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+PERL5LIB=/srv/www/travelynx/local/lib/perl5
+MAILTO=root
+
+*/3 * * * * travelynx timeout 5m perl /srv/www/travelynx/index.pl work -m production
diff --git a/examples/docker/email-transport.sh b/examples/docker/email-transport.sh
new file mode 100644
index 0000000..c04f187
--- /dev/null
+++ b/examples/docker/email-transport.sh
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+export EMAIL_SENDER_TRANSPORT=SMTP
+export EMAIL_SENDER_TRANSPORT_HOST=smtp.example.com
+export EMAIL_SENDER_TRANSPORT_PORT=25
diff --git a/examples/docker/travelynx.conf b/examples/docker/travelynx.conf
deleted file mode 100644
index b3dc003..0000000
--- a/examples/docker/travelynx.conf
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- cache => {
- schedule => $ENV{TRAVELYNX_IRIS_CACHE} // '/var/cache/travelynx/iris',
- realtime => $ENV{TRAVELYNX_IRISRT_CACHE} // '/var/cache/travelynx/iris-rt',
- },
- db => {
- host => $ENV{TRAVELYNX_DB_HOST} // die("Please set TRAVELYNX_DB_HOST"),
- database => $ENV{TRAVELYNX_DB_NAME} // 'travelynx',
- user => $ENV{TRAVELYNX_DB_USERNAME} // 'travelynx',
- password => $ENV{TRAVELYNX_DB_PASSWORD} // die("Please set TRAVELYNX_DB_PASSWORD"),
- },
- hypnotoad => {
- accepts => $ENV{TRAVELYNX_HYPNOTOAD_ACCEPTS} // 100,
- clients => $ENV{TRAVELYNX_HYPNOTOAD_CLIENTS} // 10,
- listen => [ $ENV{TRALELYNX_HYPNOTOAD_LISTEN} // 'http://*:8093' ],
- pid_file => '/tmp/travelynx.pid',
- workers => $ENV{TRAVELYNX_HYPNOTOAD_WORKERS} // 2,
- spare => $ENV{TRAVELYNX_HYPNOTOAD_SPARE} // 2,
- },
- mail => {
- disabled => $ENV{TRAVELYNX_MAIL_DISABLE} // 0,
- },
- secrets => [
- $ENV{TRAVELYNX_SECRET} // die("Please set TRAVELYNX_SECRET"),
- ],
-};
diff --git a/examples/nginx/travelynx.conf b/examples/nginx/travelynx.conf
new file mode 100644
index 0000000..da8426e
--- /dev/null
+++ b/examples/nginx/travelynx.conf
@@ -0,0 +1,40 @@
+upstream travelynx {
+ server 127.0.0.1:8093;
+}
+
+server {
+ listen [::]:80;
+ listen 0.0.0.0:80;
+
+ server_name travelynx.de;
+ access_log /var/log/nginx/de.travelynx.log anonip;
+
+ rewrite ^/(.*)$ https://travelynx.de/$1 permanent;
+}
+
+
+server {
+ listen [::]:443;
+ listen 0.0.0.0:443;
+
+ server_name travelynx.de;
+ access_log /var/log/nginx/de.travelynx.log anonip;
+
+ location /static {
+ expires 1y;
+ root /srv/www/travelynx/public;
+ }
+
+ location /service-worker.js {
+ expires 1d;
+ root /srv/www/travelynx/public;
+ }
+
+ location / {
+ proxy_pass http://travelynx;
+ proxy_http_version 1.1;
+ proxy_set_header Host $host;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto "http";
+ }
+}
diff --git a/examples/travelynx.conf b/examples/travelynx.conf
index fe3e960..fdcd03e 100644
--- a/examples/travelynx.conf
+++ b/examples/travelynx.conf
@@ -2,9 +2,22 @@
# travelynx.conf must be a valid perl hash reference. String values must be
# quoted and hash items must end with a comma. You can access environment
# variables via $ENV, e.g. by writing $ENV{TRAVELYNX_DB_HOST} instead of
-# 'localhost'.
+# 'localhost'. You can validate via 'perl -c travelynx.conf'.
{
+ # Optional announcement, e.g. to indicate maintenance or backend issues.
+ #announcement => 'The IRIS backend is flaky. Real-time data may not be available.',
+
+ # Base URL of this travelynx installation, e.g. "https://travelynx.de" for
+ # travelynx.de. Used to identify this travelynx instance when performing API
+ # requests (so API providers know whom to contact case of issues) and for
+ # imprint and other links in travelynx E-Mails. Note that this entry is
+ # only used when travelynx is performing requests or sending E-mails from
+ # a "work", "worker", or "maintenance" job. Otherwise, it will infer the
+ # base URL from the HTTP request. If your travelynx instance is reachable
+ # via multiple URLs, use any one of them.
+ base_url => Mojo::URL->new('https://FIXME.local'),
+
# Cache directories for schedule and realtime data. Mandatory. The parent
# directory ('/var/cache/travelynx' in this case) must already exist.
cache => {
@@ -22,16 +35,39 @@
password => die("Changeme!"),
},
- mail => {
- # If you want to disable outgoing mail for development purposes,
- # uncomment the following line. Mails will instead be logged as
- # Mojolicious "info" messages, causing their content to be printed on
- # stdout.
- ## disabled => 1,
+ # Settings specific to the DBRIS bahn.de backend.
+ # Their journey endpoint (which is required for checkins) is behind an IP
+ # reputation filter, denying requests from most non-residential IP ranges.
+ # If needed, you can specify either a single SOCKS proxy or a set of
+ # SOCKS proxies here, and thus work around that limitation. If multiple
+ # proxies are specified, travelynx will choose a random one for each
+ # request. Note that DBRIS bahn.de requests to non-journey endpoints
+ # (such as the departure board) are always sent directly and not passed
+ # through the proxy / proxies specified here.
+ # "proxies" takes precedence over "proxy".
+ dbris => {
+ 'bahn.de' => {
+ # proxy => 'socks://127.0.0.1:18080', # <- either this
+ # proxies => ['socks://127.0.0.1:18080', 'socks://127.0.0.1:18081'],
+ },
},
- # See the Mojo::Server::Hypnotoad manual for details on the following
- # settings.
+ # Settings specific to HAFAS backends.
+ # For instance, the PKP backend is hidden behind a GeoIP filter, hence
+ # travelynx only supports it if travelynx.conf either indicates that it
+ # is reachable or specifies a proxy.
+ hafas => {
+ PKP => {
+ # geoip_ok => 1, # <- either this
+ # proxy => 'socks://...', # <- or this
+ },
+ },
+
+ # These settings control the amount and (re)spawn behaviour of travelynx
+ # worker processes as well as IP, port, and PID file. They are suitable for
+ # up to a few dozen concurrent users. If your site has more traffic, you
+ # may want to increase the number of worker processes.
+ # See the Mojo::Server::Hypnotoad manual for details.
hypnotoad => {
accepts => 100,
clients => 10,
@@ -41,6 +77,46 @@
spare => 2,
},
+ influxdb => {
+ # travelynx can log statistics and performance attributes to InfluxDB.
+ # To do so, create a travelynx database in your InfluxDB, and point url
+ # (below) to the corresponding write URL. The URL may use anything from
+ # plain HTTP to HTTPS with password authentication.
+ ## url => 'https://user:password@host/write?db=travelynx',
+ },
+
+ mail => {
+ # To disable outgoing mail for development purposes, uncomment the
+ # following line. Mails will instead be logged as Mojolicious "info"
+ # messages, causing their content to be printed on stdout.
+ ## disabled => 1,
+
+ # Otherwise, specify the sender ("From" field) for mail sent by travelynx
+ # here. E.g. 'Travelynx <mail@example.org>'
+ from => die("Changeme!"),
+ },
+
+ registration => {
+ # To disable registration for your instance, uncomment the following
+ # line.
+ ## disabled => 1,
+
+ # To block registration from certain IPs, uncomment the following line
+ # and point it to a file containing one IPv4 or IPv6 address per line.
+ # Blocking IP ranges is not supported.
+ ## denylist => "denylist.txt",
+ },
+
+ # Links to source code and issue tracker shown on the about page.
+ # Please change them if you are using a fork.
+ ref => {
+ # Optional
+ issues => 'https://github.com/derf/travelynx/issues',
+
+ # Mandatory
+ source => 'https://github.com/derf/travelynx',
+ },
+
# Secrets used for cookie signing and verification. Must contain at least
# one random string. If you specify several strings, the first one will
# be used for signing new cookies, and the remaining ones will still be
@@ -49,5 +125,46 @@
die("Changeme!"),
],
+ # optionally, users can link travelynx and traewelling accounts, and
+ # automatically synchronize check-ins.
+ # To do so, you need to create a travelynx application on
+ # <https://traewelling.de/settings/applications>. The application
+ # must be marked as "Confidential" and have a redirect URL that matches
+ # $base_url/oauth/traewelling, where $base_url refers to the URL configured
+ # above. For instance, travelynx.de uses
+ # 'https://travelynx.de/oauth/traewelling'. An incorrect redirect URL will
+ # cause OAuth2 to fail with unsupported_grant_type.
+ #
+ # Note that the travelynx/traewelling OAuth2 integration does not support
+ # travelynx installations that are reachable on multiple URLs at the
+ # moment -- linking a traewelling account is only possible when accessing
+ # travelynx via the base URL.
+ traewelling => {
+
+ # Uncomment the following block and insert the application ID and
+ # secret obtained from https://traewelling.de/settings/applications
+ # -> your application -> Edit.
+
+ #oauth => {
+ # id => 1234,
+ # secret => 'mysecret',
+ #}
+
+ # By default, the "work" or "worker" command does not just update
+ # real-time data of active journeys, but also performs push and pull
+ # synchronization with traewelling for accounts that have configured it.
+ # Traewelling pull synchronization currently relies on polling the user
+ # status on traewelling.de, so large travelynx instances may want to
+ # run pull synchronization less frequently than regular "work" commands
+ # and traewelling push synchronization.
+ #
+ # To do so, uncomment "separate_worker" below and create a cronjob that
+ # periodically runs "perl index.pl traewelling" (push and pull) or
+ # two separate cronjobs that run "perl index.pl traewelling push" and
+ # "perl index.pl traewelling pull", respectively.
+
+ # separate_worker => 1,
+ },
+
version => qx{git describe --dirty} // 'experimental',
};
diff --git a/examples/travelynx.service b/examples/travelynx.service
index 0a2b2d5..4dbedbb 100644
--- a/examples/travelynx.service
+++ b/examples/travelynx.service
@@ -1,5 +1,5 @@
[Unit]
-Description=travelynx.finalrewind.org
+Description=Travelynx Railway Checkin Service
After=network.target
[Service]
@@ -7,15 +7,15 @@ Type=simple
RemainAfterExit=yes
PIDFile=/tmp/travelynx.pid
-ExecStart=/usr/bin/hypnotoad -f index.pl
-ExecStop=/usr/bin/hypnotoad -s index.pl
-ExecReload=/usr/bin/hypnotoad index.pl
+ExecStart=/srv/www/travelynx/local/bin/hypnotoad -f index.pl
+ExecStop=/srv/www/travelynx/local/bin/hypnotoad -s index.pl
+ExecReload=/srv/www/travelynx/local/bin/hypnotoad index.pl
User=travelynx
WorkingDirectory=/srv/www/travelynx
Environment=LANG=en_US.UTF-8
-
+Environment=PERL5LIB=/srv/www/travelynx/local/lib/perl5
[Install]
WantedBy=multi-user.target