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

Tutorial: Set up on Linux server #139

Closed
Lyamc opened this issue Apr 30, 2021 · 11 comments
Closed

Tutorial: Set up on Linux server #139

Lyamc opened this issue Apr 30, 2021 · 11 comments

Comments

@Lyamc
Copy link

Lyamc commented Apr 30, 2021

Tested with Ubuntu 21.04

1: Get nightly rust from rustup.rs

2: Get dependencies and build

sudo apt install -y libarchive-tools
cd ~
git clone https://github.com/agersant/polaris
cd polaris
cargo build --release
cd ~

3: Install

echo "Creating config dir"
sudo mkdir -p /etc/polaris
sudo cp ~/polaris/test-data/config.toml /etc/polaris/polaris.toml

echo "Creating swagger and web directories"
sudo mkdir -p /usr/share/polaris
sudo cp ~/polaris/docs/swagger /usr/share/polaris/

echo "Getting web files"
cd /usr/share/polaris
wget -qO- https://github.com/agersant/polaris-web/releases/download/build-50/web.zip | sudo bsdtar -xvf-
cd ~

echo "Copying binary to cargo default"
mkdir -p ~/.cargo/bin
cp -f ~/polaris/target/release/polaris ~/.cargo/bin

echo "Cleaning up polaris build files"
rm -rf ~/polaris

echo "Adding polaris user"
sudo useradd polaris

echo "Setting permissions for polaris"
sudo chown -R polaris:polaris /usr/share/polaris
sudo mkdir -p /var/lib/polaris
sudo chown -R polaris:polaris /var/lib/polaris
sudo mkdir -p /var/log/polaris
sudo chown -R polaris:polaris /var/log/polaris

echo "Copying binary to default bin PATH"
sudo cp -f ~/.cargo/bin/polaris /usr/bin/polaris

4: Configure

sudo ufw allow 5050
sudo nano /etc/polaris/polaris.toml

5: Enable and start the service (paste the entire thing into the terminal)

cat << SERVICE_CMD | sudo tee /etc/systemd/system/polaris.service
[Unit]
Description=Polaris
After=network.target

[Service]
User=polaris
ExecStart=/usr/bin/polaris -f -w /usr/share/polaris/web -s /usr/share/polaris/swagger -c /etc/polaris/polaris.toml -d /var/lib/polaris/polaris.db --log /var/log/polaris/polaris.log
WorkingDirectory=/var/lib/polaris

[Install]
WantedBy=default.target

SERVICE_CMD
sudo systemctl daemon-reload
sudo systemctl enable --now polaris

6: Navigate to <your-ip>:5050

image

@lnicola
Copy link
Contributor

lnicola commented Apr 30, 2021

There's a systemd unit in #39 (comment).

@Lyamc
Copy link
Author

Lyamc commented Apr 30, 2021

Thanks!

Also, I see that the server already is using particular directories when running cargo install --path . so I think I'll rewrite this again tomorrow with the correct directories.

@lnicola
Copy link
Contributor

lnicola commented Apr 30, 2021

Yeah, there's some discussion in #39 and #91 about the paths it should use. And I'd also avoid running it as root -- not that I don't find it trustworthy, but it's good practice to create separate users for daemons.

@Lyamc
Copy link
Author

Lyamc commented Apr 30, 2021

Good point!

@lnicola
Copy link
Contributor

lnicola commented Apr 30, 2021

Wait, is nightly still required? It was needed for Rocket, but that's no longer used.

@Lyamc
Copy link
Author

Lyamc commented Apr 30, 2021

I got an error when I tried to build with sudo apt install cargo and then cargo build --release so it could be the version ubuntu has.

Compiling crossbeam-deque v0.8.0
error[E0658]: use of unstable library feature 'seek_convenience'
  --> /home/lyam/.cargo/registry/src/github.com-1ecc6299db9ec823/id3-0.6.4/src/chunk.rs:70:36
   |
70 |             let id3_tag_pos = file.stream_position()?;
   |                                    ^^^^^^^^^^^^^^^
   |
   = note: see issue #59359 <https://github.com/rust-lang/rust/issues/59359> for more information

error[E0658]: use of unstable library feature 'seek_convenience'
  --> /home/lyam/.cargo/registry/src/github.com-1ecc6299db9ec823/id3-0.6.4/src/chunk.rs:96:28
   |
96 |             let pos = file.stream_position()?;
   |                            ^^^^^^^^^^^^^^^
   |
   = note: see issue #59359 <https://github.com/rust-lang/rust/issues/59359> for more information

error[E0658]: use of unstable library feature 'seek_convenience'
   --> /home/lyam/.cargo/registry/src/github.com-1ecc6299db9ec823/id3-0.6.4/src/chunk.rs:128:14
    |
128 |             .stream_position()?
    |              ^^^^^^^^^^^^^^^
    |
    = note: see issue #59359 <https://github.com/rust-lang/rust/issues/59359> for more information

error[E0658]: use of unstable library feature 'seek_convenience'
   --> /home/lyam/.cargo/registry/src/github.com-1ecc6299db9ec823/id3-0.6.4/src/chunk.rs:199:22
    |
199 |     let pos = reader.stream_position()?;
    |                      ^^^^^^^^^^^^^^^
    |
    = note: see issue #59359 <https://github.com/rust-lang/rust/issues/59359> for more information

   Compiling sha2 v0.9.2
   Compiling sha-1 v0.9.2
error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0658`.
error: could not compile `id3`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

@lnicola
Copy link
Contributor

lnicola commented Apr 30, 2021

I mean, stable might also work. You've switched from nightly to whatever old version Ubuntu has.

@Lyamc
Copy link
Author

Lyamc commented Apr 30, 2021

That's true, either way Ubuntu will require a person to get cargo either through rustup.rs or through the snap packages.

I updated the tutorial! I think it's good enough to be combined into a install.sh script that someone could curl to install (the nano command would have to be adjusted to something else)

@Lyamc
Copy link
Author

Lyamc commented Apr 30, 2021

I someone wants to access this from behind a reverse proxy like Sozu, I can provide an example config

@lnicola
Copy link
Contributor

lnicola commented Apr 30, 2021

Might be worth pasting it to #118, someone could make a PR out of that thread.

@agersant
Copy link
Owner

agersant commented Apr 30, 2021

Thank you for putting this together! It is a good idea to describe an example installation for a typical system with systemd and ufw.

I think steps 2 and 3 could be simplified by using a release tarball instead of cloning master. The releases include a compatible build of the web client and also a makefile which can simplify build and installation (see details).

Edit: recent changes to the rust-id3 dependency require Rust 1.51 (latest stable), which would explain the build issues described above.

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

No branches or pull requests

3 participants