sweet-tooth-clojure.clojure-uberjar-webapp-app

Clojure Uberjar Webapp: Application

This role sets up a server to run a standalone Java program as a web server. It does the following:

  • Installs the necessary packages to run a Java program (openjdk-8-jre).
  • Sets up a script to run the program as a service using upstart.
  • Uses environment variables to configure your program.

For a quick overview and instructions, visit this GitHub link. For an introductory guide to Ansible and detailed information about this role, check out Deploying Your First Clojure App ...From the Shadows.

Requirements

None

Role Variables

I tried to make the configuration flexible while keeping most defaults defined. You only need to set a few variables for everything to work. If you set clojure_uberjar_webapp_domain, the role will automatically define clojure_uberjar_webapp_app_name, which most variables below will use.

For example, if your domain is foo.bar.com, the app name will be foo-bar-com. Your Java jar will be uploaded to /var/www/foo-bar-com/foo-bar-com.jar. The upstart service will be named foo-bar-com, and logs will be located at /var/log/foo-bar-com/foo-bar-com.log. This consistency makes it easier to navigate the filesystem.

While there are some mentions of datomic variables, they are optional. I plan to enhance the roles so this one has no datomic references.

Variable Description
clojure_uberjar_webapp_app_user The user that owns the app-related files
clojure_uberjar_webapp_app_http_port Sets the HTTP_SERVER_PORT environment variable when starting the jar
clojure_uberjar_webapp_app_http_env_path Path for the file exporting HTTP_SERVER_PORT, sourced in upstart
clojure_uberjar_webapp_app_service_name Name used by upstart for the service, e.g. sudo service xyz start
clojure_uberjar_webapp_app_jar_name Name used when copying the jar file to the server
clojure_uberjar_webapp_app_env_local_path Path on the local machine for the file setting other environment variables
clojure_uberjar_webapp_app_env_path Path to save the file for setting app environment variables, sourced in upstart
clojure_uberjar_webapp_app_check_local_path Path on the local machine for a script template to check the deployment
clojure_uberjar_webapp_app_command Command used in the upstart script to start the web app

Dependencies

Example Playbook

---
- hosts: webservers
  become: true
  become_method: sudo
  roles:
    - "sweet-tooth-clojure.clojure-uberjar-webapp-common"
    - "sweet-tooth-clojure.clojure-uberjar-webapp-nginx"
    - "sweet-tooth-clojure.clojure-uberjar-webapp-datomic-free"
    - "sweet-tooth-clojure.clojure-uberjar-webapp-app"

GitHub Repository

GitHub Repo

License

MIT License

Author Information

Daniel Higginbotham

Informazioni sul progetto

Run an uberjar web app

Installa
ansible-galaxy install sweet-tooth-clojure.clojure-uberjar-webapp-app
Licenza
Unknown
Download
408
Proprietario