Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6131177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:56:38+00:00 2026-05-23T16:56:38+00:00

How can I use EventMachine.connect_unix_domain while running Thin as a service (using the init

  • 0

How can I use EventMachine.connect_unix_domain while running Thin as a service (using the init script (excerpt) and configuration below). The code directly below is the problem (I get an eventmachine not initialized: evma_connect_to_unix_server error). The second code example works, but doesn’t allow me to daemonize thin (I don’t think). Does Thin not already have a running instance of EventMachine?

UPDATE: Oddly enough: stopping the server (with service thin stop), seems to get into the config.ru file and run the app (so it works, until the stop command times out and kills the process). What happens when thin stops that could be causing this behavior?

Problematic Code

class Server < Sinatra::Base
# Webserver code removed
end

module Handler
  def receive_data data
    $received_data_changed = 1
    $received_data = data
  end
end

$sock = EventMachine.connect_unix_domain("/tmp/mysock.sock", Handler)

Working Code

EventMachine.run do
  class Server < Sinatra::Base
  # Webserver code removed
  end

  module Handler
    def receive_data data
      $received_data_changed = 1
      $received_data = data
    end
  end
  $sock = EventMachine.connect_unix_domain("/tmp/mysock.sock", Handler)
  Server.run!(:port => 4567)
end

Init Script excerpt

DAEMON=/usr/local/bin/thin
SCRIPT_NAME=/etc/init.d/thin
CONFIG_PATH=/etc/thin

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

case "$1" in
  start)
    $DAEMON start --all $CONFIG_PATH
    ;;

Thin Config

--- 
chdir: /var/www
environment: development
timeout: 30
log: log/thin.log
pid: tmp/pids/thin.pid
max_conns: 1024
max_persistent_conns: 512
require: []

wait: 30
servers: 1
socket: /tmp/thin.server.sock
daemonize: true
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:56:38+00:00Added an answer on May 23, 2026 at 4:56 pm

    What I ended up doing was removing the EventMachine.run do ... end and simply enclosing the socket connection in an EM.next_tick{ $sock = EventMachine.connect_unix_domain("/tmp/mysock.sock", Handler) }.

    Could swear I tried this once before… but it works now.

    EDIT: Idea for next_tick came from here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

You can use command lsof to get file descriptors for all running processes, but
we use Rails and EventMachine together, and when using that combo with Passenger there
I can use the following code for tiny little queries: DECLARE @sql VARCHAR(8000) SET
can i use hibernate to login jsp page using (session) if i'm not using
I'm learning thin server, by now I can use thin start to fire up
Can i use the SqlAlchemy ORM-Mapper to only generate the SQL-Code? With simple tables
we can use both the method while passing parameters to sql query ? then
How can use the WebBrowser control in WPF to navigate using Search engine uri
I can use vi{ and va{ to select C++ code blocks. It helps me
how can use JS variable in PHP like this ? <script> x = document.getElementById(1).value;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.