add supysonic daemon

This commit is contained in:
vincent 2019-11-17 17:12:24 +01:00
parent 5045249644
commit 7fa9bf43c0
5 changed files with 49 additions and 11 deletions

View File

@ -15,4 +15,5 @@ supysonic_db_user: supysonic
# Database password, please change when using the role
supysonic_db_password: supysonic
# Database name
supysonic_db_name: supysonic
supysonic_db_name: supysonic
supysonic_log_level: INFO

View File

@ -13,4 +13,11 @@
name: "gunicorn-{{supysonic_name}}.service" # not required. Name of the service. When using in a chroot environment you always need to specify the full name i.e. (crond.service).
state: restarted # not required. choices: reloaded;restarted;started;stopped. C(started)/C(stopped) are idempotent actions that will not run commands unless necessary. C(restarted) will always bounce the service. C(reloaded) will always reload.
enabled: true
become: yes
become: yes
- name: restart daemon service
systemd:
name: "{{supysonic_name}}-daemon.service" # not required. Name of the service. When using in a chroot environment you always need to specify the full name i.e. (crond.service).
state: restarted # not required. choices: reloaded;restarted;started;stopped. C(started)/C(stopped) are idempotent actions that will not run commands unless necessary. C(restarted) will always bounce the service. C(reloaded) will always reload.
enabled: true
become: yes

View File

@ -34,7 +34,7 @@
become: yes
when: location_stat.stat.exists == false or supysonic_force_site_update == true
notify:
- restart supysonic service
- restart supysonic service
- name: create folder in var
file:
@ -62,18 +62,19 @@
virtualenv: "{{venv_location}}{{supysonic_venv_name}}" # not required. An optional path to a I(virtualenv) directory to install into. It cannot be specified together with the 'executable' parameter (added in 2.1). If the virtualenv does not exist, it will be created before installing packages. The optional virtualenv_site_packages, virtualenv_command, and virtualenv_python options affect the creation of the virtualenv.
name: pymysql
- name: apply systemd service template
- name: apply config template
template:
dest: "/etc/supysonic" # required. Location to render the template to on the remote machine.
src: "supysonic.j2" # required. Path of a Jinja2 formatted template on the Ansible controller. This can be a relative or absolute path.
become: yes
notify:
- restart supysonic service
- restart supysonic service
- restart daemon service
- name: install gunicorn
pip:
virtualenv: "{{venv_location}}{{supysonic_venv_name}}" # not required. An optional path to a I(virtualenv) directory to install into. It cannot be specified together with the 'executable' parameter (added in 2.1). If the virtualenv does not exist, it will be created before installing packages. The optional virtualenv_site_packages, virtualenv_command, and virtualenv_python options affect the creation of the virtualenv.
name: gunicorn # not required. The name of a Python library to install or the url(bzr+,hg+,git+,svn+) of the remote package.,This can be a list (since 2.2) and contain version specifiers (since 2.7).
virtualenv: "{{venv_location}}{{supysonic_venv_name}}" # not required. An optional path to a I(virtualenv) directory to install into. It cannot be specified together with the 'executable' parameter (added in 2.1). If the virtualenv does not exist, it will be created before installing packages. The optional virtualenv_site_packages, virtualenv_command, and virtualenv_python options affect the creation of the virtualenv.
name: gunicorn # not required. The name of a Python library to install or the url(bzr+,hg+,git+,svn+) of the remote package.,This can be a list (since 2.2) and contain version specifiers (since 2.7).
- name: apply systemd service template
@ -82,8 +83,23 @@
src: "systemd/gunicorn.service.j2" # required. Path of a Jinja2 formatted template on the Ansible controller. This can be a relative or absolute path.
become: yes
notify:
- Reload systemd
- restart supysonic service
- Reload systemd
- restart supysonic service
- name: apply systemd daemon template
template:
dest: "/etc/systemd/system/{{supysonic_name}}-daemon.service" # required. Location to render the template to on the remote machine.
src: "systemd/supysonic-daemon.service.j2" # required. Path of a Jinja2 formatted template on the Ansible controller. This can be a relative or absolute path.
become: yes
notify:
- Reload systemd
- restart daemon service
- name: enable daemon service
systemd:
name: "gunicorn-{{supysonic_name}}.service" # not required. Name of the service. When using in a chroot environment you always need to specify the full name i.e. (crond.service).
enabled: true
become: yes
- name: enable supysonic service
systemd:

View File

@ -22,7 +22,7 @@ transcode_cache_size = 1024
log_file = /var/supysonic/supysonic.log
; Log level. Possible values: DEBUG, INFO, WARNING, ERROR, CRITICAL. Default: WARNING
log_level = WARNING
log_level = {{supysonic_log_level}}
; Enable the Subsonic REST API. You'll most likely want to keep this on, here for testing purposes. Default: on
;mount_api = on
@ -35,10 +35,11 @@ log_level = WARNING
; This prevents running too many scans when multiple changes are detected for a
; single file over a short time span. Default: 5
wait_delay = 5
socket = /var/run/supysonic.sock
; Optional rotating log file for the scanner daemon. Logs to stderr if empty
log_file = /var/supysonic/supysonic-daemon.log
log_level = INFO
log_level = {{supysonic_log_level}}
[lastfm]
; API and secret key to enable scrobbling. http://www.last.fm/api/accounts

View File

@ -0,0 +1,13 @@
[Unit]
Description=Supysonic Daemon
[Service]
User=root
Group=root
WorkingDirectory={{source_location}}/{{supysonic_name}}
ExecStart={{venv_location}}{{supysonic_venv_name}}/bin/python -m supysonic.daemon
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
[Install]
WantedBy=multi-user.target