-
-
Notifications
You must be signed in to change notification settings - Fork 76
Run uvicorn at boot
Having to run uvicorn manually is annoying and not maintainable.
Instead, you should have the system automatically start it at boot for you.
We can have systemd
handle lauching uvicorn by creating a unit file for it.
Create a new file called etebase_server.service
and paste in the following.
Don't forget to set the correct path to your installation and to your venv, as well as the correct user and group.
[Unit]
Description=Execute the etebase server.
[Service]
WorkingDirectory=/path/to/etebase
ExecStart=/path/to/etebase/.venv/bin/uvicorn etebase_server.asgi:application --uds /tmp/etebase_server.sock
[Install]
WantedBy=multi-user.target
Note that we directly run the uvicorn which is located in our virtual environment (at /path/to/etebase/.venv
).
If your virtual environment is located elsewhere, be sure to update this.
Next, copy this to /etc/systemd/system/
.
systemd
should now be able to start it.
By also enabling it, it will launch at boot.
$ sudo cp etebase_server.service /etc/systemd/system
$ sudo systemctl start etebase_server
$ sudo systemctl enable etebase_server
Check to see if it worked!
If it didn't work, use the command sudo systemctl status etebase_server
to see what went wrong.
Create a rc script in /usr/local/etc/rc.d/etesync
as it's not part of the base system.
#!/bin/sh
#
# PROVIDE: etesync
# REQUIRE: NETWORKING LOGIN postgresql
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable etesync:
#
#etesync_enable="YES"
. /etc/rc.subr
name="etesync"
rcvar="etesync_enable"
load_rc_config $name
: ${etesync_enable="NO"}
pidfile="/var/run/etesync/etesync.pid"
procname="/usr/local/share/etesync/venv/bin/uvicorn"
command="/usr/sbin/daemon"
command_interpreter="/usr/local/share/etesync/venv/bin/python3.9"
command_args="-f -u www -o /var/log/etesync.log -p ${pidfile} /usr/local/share/etesync/venv/bin/uvicorn etebase_server.asgi:application --uds /var/run/etesync/etesync.socket --env-file /usr/local/etc/etesync/etesync_env --app-dir /usr/local/share/etesync"
run_rc_command "$1"
Then place your installation in /usr/local/share/etesync
and the venv itself in /usr/local/share/etesync/venv
In /usr/local/etc/etesync/etesync_env
, place the following :
ETEBASE_EASY_CONFIG_PATH=/usr/local/etc/etesync/etesync.ini
In /usr/local/etc/etesync/etesync.ini
place your configuration as explained in other wiki sections.
Then you just have to add etesync_enable="YES"
in /etc/rc.conf
or run `rc_enable
- Home
- Setting up an Etebase Server (EteSync v2)
- Migration from SQLite to PostgreSQL
- Backups