Giter Club home page Giter Club logo

unicorn-ng's People

Contributors

chr4 avatar mb-dev avatar orthographic-pedant avatar prognostikos avatar wbotelhos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

unicorn-ng's Issues

Allow having multiple unicorn services?

If I have multiple rails applications on the same machine I would want to create multiple unicorn services.

Would it be possible to allow unicorn_ng_service to accept the name of the init.d script and would restart that.

Unicorn doesn't start

I really can't figure out why the start service doesn't work.

If I run unicorn -E staging -D -c /path/to/unicorn.rb in the current folder everything works fine.

But from the /etc/init.d file it always complains that the config.ru is missing.

It seems like it has to cd to the current directory or so to be able to start unicorn appropriately.

Would you mind taking a look?

node config

"unicorn-ng": {
  "config": {
    "worker_processes": 16,
    "listen"      : "/tmp/unicorn.myapp_staging.sock",
    "config_file" : "/home/deployer/apps/myapp_staging/shared/config/unicorn.rb",
    "pid"         : "/home/deployer/apps/myapp_staging/shared/pids/unicorn.pid",
    "stderr_path" : "/home/deployer/apps/myapp_staging/shared/log/unicorn.stderr.log",
    "stdout_path" : "/home/deployer/apps/myapp_staging/shared/log/unicorn.stdout.log"
  },
  "service": {
    "name": "myapp_staging",
    "rails_root"    : "/home/deployer/apps/myapp_staging/current",
    "config"        : "/home/deployer/apps/myapp_staging/shared/config/unicorn.rb",
    "pidfile"       : "/home/deployer/apps/myapp_staging/shared/pids/unicorn.pid",
    "environment": "staging",
    "user": "deployer",
    "owner": "root",
    "group": "root"
  }
}

rendered service

#!/bin/bash

### BEGIN INIT INFO
# Provides:          myapp_staging
# Required-Start:    $local_fs $remote_fs $network $syslog
# Required-Stop:     $local_fs $remote_fs $network $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the unicorn web server
# Description:       starts unicorn using start-stop-daemon
### END INIT INFO

export BUNDLE_GEMFILE="/home/deployer/apps/myapp_staging/current/Gemfile"

SHELL=/bin/bash
DAEMON="/usr/local/rvm/gems/ruby-2.1.1@global/bin/bundle"
DAEMON_OPTS="exec unicorn -D -E staging -c /home/deployer/apps/myapp_staging/shared/config/unicorn.rb"

COMMAND="$DAEMON -- $DAEMON_OPTS"

PIDFILE="/home/deployer/apps/myapp_staging/shared/pids/unicorn.pid"
USER="deployer"
LANG="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
LANGUAGE="en_US.UTF-8"

NAME=myapp_staging
DESC=myapp_staging

. /lib/lsb/init-functions

check_daemon() {
  if [ ! -x ${COMMAND%% *} ]; then
    log_action_msg "${COMMAND%% *} not found" || true
    log_end_msg 1 || false
    exit 1
  fi
}

case "$1" in
  start)
    log_daemon_msg "Starting $NAME" || true
    check_daemon

    if [ -s $PIDFILE ] && kill -0 $(cat $PIDFILE) > /dev/null 2>&1; then
      log_action_msg "apparently already running" || true
      log_end_msg 0 || true
      exit 0
    fi

    if start-stop-daemon --start --quiet --pidfile $PIDFILE --chuid $USER --exec $COMMAND; then
      log_end_msg 0 || true
    else
      log_end_msg 1 || false
    fi
    ;;

  stop)
    log_daemon_msg "Stopping $NAME" || true

    if start-stop-daemon --stop --quiet --pidfile $PIDFILE --chuid $USER; then
      log_end_msg 0 || true
    else
      log_end_msg 1 || false
    fi
    ;;

  restart)
    if [ -s $PIDFILE ] && kill -0 $(cat $PIDFILE) > /dev/null 2>&1; then
      log_daemon_msg "Restarting $NAME" || true

      # send SIGUSR2 to duplicate unicorn
      # before_fork will take care of qutting the old one
      if start-stop-daemon --stop --signal USR2 --quiet --pidfile $PIDFILE --chuid $USER; then
        log_end_msg 0 || true
      else
        log_end_msg 1 || false
      fi

    else
      $0 start
    fi
    ;;

  full-restart)
    $0 stop
    sleep 1
    $0 start
    ;;

  reload)
    # send SIGHUP to gracefully restart all workers
    log_daemon_msg "Reloading $NAME" || true

    if start-stop-daemon --stop --signal HUP --quiet --pidfile $PIDFILE --chuid $USER; then
      log_end_msg 0 || true
    else
      log_end_msg 1 || false
    fi
    ;;

  add-worker)
    # send SIGTTIN to tell unicorn to spawn an additional worker
    log_daemon_msg "Adding one $NAME worker" || true

    if start-stop-daemon --stop --signal TTIN --quiet --pidfile $PIDFILE --chuid $USER; then
      log_end_msg 0 || true
    else
      log_end_msg 1 || false
    fi
    ;;

  remove-worker)
    # send SIGTTOU to tell unicorn to stop one worker
    log_daemon_msg "Removing one $NAME worker" || true

    if start-stop-daemon --stop --signal TTOU --quiet --pidfile $PIDFILE --chuid $USER; then
      log_end_msg 0 || true
    else
      log_end_msg 1 || false
    fi
    ;;

  status)
    if status_of_proc -p $PIDFILE "$DAEMON" unicorn; then
      WORKERS=$(ps ax |grep "unicorn worker" |grep -v grep |wc -l)
      log_action_msg "Current workers: $WORKERS"
      exit 0
    else
      exit 1
    fi
    ;;
  *)
    echo "Usage: $NAME {start|stop|restart|full-restart|reload|status|add-worker|remove-worker}" >&2
    exit 1
    ;;
esac

exit 0

ERROR: can't modify frozen Chef::Node::ImmutableMash

Hi,

After some period where I did not update my server code, i'm facing the following error:

* apt_package[nodejs] action install (up to date)
Recipe: unicorn-ng::default
* unicorn_ng_config[default] action create[2018-02-16T05:37:21+00:00] WARN: only_if block for unicorn_ng_config[default] returned "/var/www/app/shared/config/unicorn.rb", did you mean to run a command? If so use 'only_if "/var/www/app/shared/config/unicorn.rb"' in your code.


Running handlers:
[2018-02-16T05:37:21+00:00] ERROR: Running exception handlers
Running handlers complete
[2018-02-16T05:37:21+00:00] ERROR: Exception handlers complete
Chef Client failed. 14 resources updated in 13 seconds
[2018-02-16T05:37:21+00:00] FATAL: Stacktrace dumped to /home/ubuntu/chef-solo/local-mode-cache/cache/chef-stacktrace.out
[2018-02-16T05:37:21+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2018-02-16T05:37:21+00:00] ERROR: can't modify frozen Chef::Node::ImmutableMash
[2018-02-16T05:37:21+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
ERROR: RuntimeError: chef-solo failed. See output above.

The log is:

root@ip-10-0-1-249:~# cat /home/ubuntu/chef-solo/local-mode-cache/cache/chef-stacktrace.out
Generated at 2018-02-16 05:37:21 +0000
RuntimeError: can't modify frozen Chef::Node::ImmutableMash
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/node/immutable_collections.rb:300:in `ensure_generated_cache!'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/node/immutable_collections.rb:236:in `block (2 levels) in <class:ImmutableMash>'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/resource.rb:668:in `value_to_text'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/resource.rb:645:in `block in to_text'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/resource.rb:643:in `map'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/resource.rb:643:in `to_text'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/formatters/error_inspectors/resource_failure_inspector.rb:46:in `add_explanation'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/formatters/error_mapper.rb:72:in `resource_failed'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/formatters/base.rb:139:in `resource_failed'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/formatters/doc.rb:313:in `resource_failed'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/event_dispatch/dispatcher.rb:43:in `call'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/event_dispatch/dispatcher.rb:43:in `block in call_subscribers'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/event_dispatch/dispatcher.rb:34:in `each'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/event_dispatch/dispatcher.rb:34:in `call_subscribers'
(eval):2:in `resource_failed'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/resource.rb:603:in `rescue in run_action'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/resource.rb:589:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/runner.rb:70:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/runner.rb:98:in `block (2 levels) in converge'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/runner.rb:98:in `each'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/runner.rb:98:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/resource_collection/resource_list.rb:94:in `block in execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/resource_collection/stepable_iterator.rb:114:in `call_iterator_block'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/resource_collection/stepable_iterator.rb:103:in `iterate'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/resource_collection/resource_list.rb:92:in `execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/runner.rb:97:in `converge'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/client.rb:718:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/client.rb:713:in `catch'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/client.rb:713:in `converge'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/client.rb:752:in `converge_and_save'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/client.rb:286:in `run'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application.rb:292:in `block in fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application.rb:280:in `fork'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application.rb:280:in `fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application.rb:245:in `block in run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/local_mode.rb:44:in `with_server_connectivity'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application.rb:233:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application/client.rb:469:in `sleep_then_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application/client.rb:458:in `block in interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application/client.rb:457:in `loop'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application/client.rb:457:in `interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application/client.rb:441:in `run_application'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application.rb:59:in `run'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application/solo.rb:225:in `run'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/bin/chef-solo:25:in `<top (required)>'
/usr/bin/chef-solo:59:in `load'
/usr/bin/chef-solo:59:in `<main>'

>>>> Caused by RuntimeError: can't modify frozen Chef::Node::ImmutableMash
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/node/immutable_collections.rb:300:in `ensure_generated_cache!'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/node/immutable_collections.rb:236:in `block (2 levels) in <class:ImmutableMash>'
/home/ubuntu/chef-solo/local-mode-cache/cache/cookbooks/unicorn-ng/providers/config.rb:30:in `block (2 levels) in class_from_file'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/resource_builder.rb:66:in `instance_eval'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/resource_builder.rb:66:in `build'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/dsl/declare_resource.rb:293:in `build_resource'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/dsl/declare_resource.rb:250:in `declare_resource'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/dsl/resources.rb:38:in `template'
/home/ubuntu/chef-solo/local-mode-cache/cache/cookbooks/unicorn-ng/providers/config.rb:23:in `block in class_from_file'
(eval):2:in `block in action_create'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/provider.rb:211:in `instance_eval'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/provider.rb:211:in `compile_and_converge_action'
(eval):2:in `action_create'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/provider.rb:171:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/resource.rb:591:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/runner.rb:70:in `run_action'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/runner.rb:98:in `block (2 levels) in converge'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/runner.rb:98:in `each'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/runner.rb:98:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/resource_collection/resource_list.rb:94:in `block in execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/resource_collection/stepable_iterator.rb:114:in `call_iterator_block'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/resource_collection/stepable_iterator.rb:103:in `iterate'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/resource_collection/resource_list.rb:92:in `execute_each_resource'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/runner.rb:97:in `converge'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/client.rb:718:in `block in converge'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/client.rb:713:in `catch'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/client.rb:713:in `converge'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/client.rb:752:in `converge_and_save'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/client.rb:286:in `run'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application.rb:292:in `block in fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application.rb:280:in `fork'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application.rb:280:in `fork_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application.rb:245:in `block in run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/local_mode.rb:44:in `with_server_connectivity'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application.rb:233:in `run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application/client.rb:469:in `sleep_then_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application/client.rb:458:in `block in interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application/client.rb:457:in `loop'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application/client.rb:457:in `interval_run_chef_client'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application/client.rb:441:in `run_application'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application.rb:59:in `run'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/lib/chef/application/solo.rb:225:in `run'
/opt/chef/embedded/lib/ruby/gems/2.4.0/gems/chef-13.7.16/bin/chef-solo:25:in `<top (required)>'
/usr/bin/chef-solo:59:in `load'
/usr/bin/chef-solo:59:in `<main>'root@ip-10-0-1-249:~# 
$ chef-solo -v
Chef: 13.7.16
unicorn-ng (2.0.1)

Any idea? Thanks. :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.