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 8500773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:01:47+00:00 2026-06-11T01:01:47+00:00

I am using upstart to create a daemon for a spawned nginx python fastcgi

  • 0

I am using upstart to create a daemon for a spawned nginx python fastcgi script. If I use the below it works:

sudo start myserver

What does not work is:

sudo stop myserver
stop: Unknown instance:

Below is my conf file with the command for stopping the process. I am assuming that the command for killing hte proccess is in pre-stop script?

#!upstart
description "myserver"
author      "Test"

start on startup
stop on shutdown
respawn
#instance

script
    export HOME="/root"

    echo $$ > /var/run/myerver.pid
    exec spawn-fcgi -d /home/ubuntu/workspace/rtbopsConfig/myserver/ -f /home/ubuntu/workspace/rtbopsConfig/myserver/index.py -a 127.0.0.1 -p 9001 >> /var/log/myserver.sys.log 2>&1
end script

pre-start script
    # Date format same as (new Date()).toISOString() for consistency
    echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Starting" >> /var/log/myserver.sys.log
end script

pre-stop script
    rm /var/run/myserver.pid
    sudo kill `sudo lsof -t -i:9001`
    echo "[`date -u +%Y-%m-%dT%T.%3NZ`] (sys) Stopping" >> /var/log/myserver.sys.log
end script
  • 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-06-11T01:01:49+00:00Added an answer on June 11, 2026 at 1:01 am

    The best way to handle this would be to tell spawn-fcgi to run in the foreground, and not daemonize. The man page for spawn-fcgi says that the -n option does this. Then you can rewrite this whole upstart job as this:

    start on runlevel [2345]
    stop on runlevel [016]
    respawn    
    
    exec spawn-fcgi -n -d /home/ubuntu/workspace/rtbopsConfig/myserver/ -f /home/ubuntu/workspace/rtbopsConfig/myserver/index.py -a 127.0.0.1 -p 9001 >> /var/log/myserver.sys.log 2>&1
    

    Note that with Upstart 1.4 you don’t even need the log direction, as it defaults to ‘console log’, which would have all the output in /var/log/upstart/$UPSTART_JOB.log.. so itw ould just be

    start on runlevel [2345]
    stop on runlevel [016]
    respawn
    
    exec spawn-fcgi -n -d /home/ubuntu/workspace/rtbopsConfig/myserver/ -f /home/ubuntu/workspace/rtbopsConfig/myserver/index.py -a 127.0.0.1 -p 9001
    

    Its worth noting that this runs as root, but it listens on port 9001. So you would probably be better off running as nobody. With Upstart 1.5 (Ubuntu 12.04 and later again) Just add this:

    setuid nobody
    setgid nogroup
    

    (You might have to change nobody/nogroup to ubuntu/ubuntu since your files are in /home/ubuntu)

    Also note that start on startup will not work reliably, because the startup event happens before filesystems are mounted and before the network is up. Also start on shutdown just plain does not work, as it is not a real event. See man upstart-events for more events.

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

Sidebar

Related Questions

I'm using upstart v1.4 to start my application server, it's called unicorn . The
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using CSS, how can I create a partial border as per image below I
Using import datetime in python, is it possible to take a formatted time/date string
Using Jenkins or Hudson I would like to create a pipeline of builds with
I'm trying to create a sample cron job. First I've edited crontab using: crontab
I have the following two exec statements in an Ubuntu upstart script: exec /bin/su
I'm configuring my server to run node.js as a daemon. I've setup Upstart to
Using Entity Framework CodeFirst, how do I create a created datetime column that gets
Using Github's Issue Tracker, how can one create an issue tied to an organization

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.