Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Bare metal development environment

Miquel Sabaté Solà edited this page May 20, 2016 · 5 revisions

Maybe you want to write code for Portus with a bare metal setup. This is not recommended, since it might conflict with whatever you might have in your machine. Anyways, here there are some tips:

  • Maybe you want to take a look at some setups that are known to work, like this NGinx setup.
  • In the .gitignore file we ignore a file named bin/portus. You might use this as a script that sets up everything to get Portus working.

As an example of the above, you might configure an NGinx + Puma setup, and then have the following bin/portus script:

#!/bin/bash

# The base directory of the project.
base="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"

# Export environment variables if needed.
if [ -z "$PORTUS_KEY_PATH" ]; then
    export PORTUS_KEY_PATH="/etc/nginx/ssl/registry.mssola.cat.key"
fi
if [ -z "$PORTUS_USE_SSL" ]; then
    export PORTUS_USE_SSL="true"
fi
if [ -z "$PORTUS_MACHINE_FQDN" ]; then
    export PORTUS_MACHINE_FQDN="registry.mssola.cat"
fi

# Check which command to use.
cmd="restart"
if [ "$1" != "" ]; then
    cmd="$1"
fi

sudo systemctl $cmd mysql nginx registry

# In Puma a restart can be troublesome. Since this script is used for
# development purposes only, a restart will mean to force the stop and then
# start.
if [ "$cmd" = "restart" ]; then
    if [ -f "$base/tmp/pids/puma.pid" ]; then
        bundle exec pumactl -F $base/../puma.rb stop
    fi
    cmd="start"
fi
bundle exec pumactl -F $base/../puma.rb $cmd

# Crono
if [ -f "$base/tmp/pids/crono.pid" ]; then
    kill -9 $(cat $base/tmp/pids/crono.pid)
    rm $base/tmp/pids/crono.pid
fi
if [ "$cmd" != "stop" ]; then
    bundle exec crono -P $base/tmp/pids/crono.pid -L $base/log/crono.log -d true
fi

Note that this script assumes that the Puma configuration is placed in the parent directory of the Portus working directory.

Clone this wiki locally