Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discussion] Adding a systemd .service file? #82

Open
Honeypot95 opened this issue Apr 2, 2021 · 2 comments
Open

[Discussion] Adding a systemd .service file? #82

Honeypot95 opened this issue Apr 2, 2021 · 2 comments

Comments

@Honeypot95
Copy link

Would there be interest in adding a systemd service file? I was unsure about a convenient way of running the service automatically at startup, without intervetion, so I wrote a personal service file for systemd.

I can contribute it, but it probably needs much more work.

Am I missing something on the way to run the sync server?

@VikashKothary
Copy link
Member

VikashKothary commented Apr 13, 2021

Hi @Honeypot95, I'm sure that would be useful for our users.

What do you think would be the best way to share this? Possibility you could add it and some explanation on how to use in our docs?

Let me know what you think?

@Honeypot95
Copy link
Author

Honeypot95 commented May 24, 2021

I have a .service file roughly as such:

[Unit]
Description=Anki sync server

[Service]
Type=simple
User=$USER
ExecStart=$HOME/anaconda3/bin/python3 -m ankisyncd
WorkingDirectory=$HOME/git/anki-sync-server/src/

[Install]
WantedBy=multi-user.target

Unfortunately, environment variables such as $HOME do not work in such files.

The best solution I think is to have this template, and ship a script that installs this file into /etc/systemd/system/, and that also expands the paths to absolute values. So the WorkingDirectory will be the directory where the ankisyncd lies.

An additional problem that I foresee is that we also have to this for the python executable. Because many people, such as myself, use different python executables than the system ones, when systemd will try to run the file, it will run it with the system python, which may not have every requirement installed.

The docs should have another step, marked optional, for running the script with sudo to install the systemd service. Additionally, maybe there is a need for a complete installation script? Something akin to make install and have everything solved, with the config file set to default values.

I will make a pull request with this idea, so we can discuss actual code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants