How do I start Unicorn using systemd/systemctl?

274

Error message Failed at step CHDIR means that systemd is unable to cd into directory specified in WorkingDirectory. It is specified as /opt/www/my-app.com but later you list it as /opt/www/my-app.

Another issue is that you are starting unicorn_rails with option -D which tells unicorn_rails process to daemonize (started process forks child and immediately exits) but your [Service] section doesn't specify Type so it defaults to simple and systemd expects process to stay alive. You need to remove -D option or specify Type=forking.

See example unit file for unicorn

Share:
274

Related videos on Youtube

Cerin
Author by

Cerin

Updated on September 18, 2022

Comments

  • Cerin
    Cerin over 1 year

    How do you "switch to" or "checkout" the branch that's the source of a pull request (especially in the eGit Eclipse plugin)?

    Since I mostly use Git for personal projects, I'm still a little new to some of its non-centralized features. I manage a few small open source projects on Github, and usually the pull requests are trivial, so it's simple enough to visually review and then merge the pull request and verify locally by running unittests before I publish elsewhere.

    However, for larger more complicated pull requests, I'd like to checkout the pull request's branch (or "switch to" it in my local project directory so I can re-use my existing virtualenv), and inspect it more thoroughly before I merge the pull request on Github. How would I do that?

    • Munir
      Munir about 8 years
      Look at the error in the log. It says Failed at step CHDIR spawning /home/deployer/.rvm/gems/ruby-2.2.1@my-app/bin/bundle: No such file or directory. That's the problem here.
    • Razvan El
      Razvan El about 8 years
      I saw that error. The file exists. If I type in the linux terminal /home/deployer/.rvm/gems/ruby-2.2.1@my-app/bin/bundle exec "unicorn_rails -D -c /opt/www/my-app.com/config/unicorn.rb -E production" the unicorn will start but apparently it doesn't work in the .service file
    • JdeBP
      JdeBP about 8 years
  • Cerin
    Cerin over 9 years
    What would be a valid value of "remotename"? Github's pull request page lists it like <username>:master, but when I try to run git remote add <username>:master https://github.com/<username>/repo, git gives me the error "fatal: <username>:master is not a valid remote name".