title: How do I start Unicorn using systemd/systemctl?
body: <p>I've wrote a <code>systemd</code> file for <code>systemctl</code> to start <code>unicorn</code>:</p>
  
  <pre><code>[Unit]
  Description=Unicorn server
  
  [Service]
  SyslogIdentifier=my-app-unicorn
  User=deployer
  PIDFile=/tmp/unicorn.my-app.pid
  WorkingDirectory=/opt/www/my-app.com
  
  ExecStart=/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"
  #ExecReload=/bin/kill -s HUP $MAINPID
  ExecReload=/bin/kill -s USR2 $MAINPID
  ExecStop=/bin/kill -s QUIT $MAINPID
  
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  
  <p>Here are the commands I used to start the service</p>
  
  <pre><code>$ sudo systemctl daemon-reload
  $ sudo systemctl start my-app.service
  </code></pre>
  
  <p>Here I check the status:</p>
  
  <pre><code>$ sudo systemctl status my-app
  ● my-app.service - My app unicorn server
     Loaded: loaded (/lib/systemd/system/my-app.service; disabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Tue 2016-03-15 14:56:31 UTC; 4s ago
    Process: 22165 ExecStop=/bin/kill -s QUIT $MAINPID (code=exited, status=200/CHDIR)
    Process: 22162 ExecStart=/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 (code=exited, status=200/CHDIR)
   Main PID: 22162 (code=exited, status=200/CHDIR)
  
  Mar 15 14:56:31 fat-man systemd[1]: Started My-App unicorn server.
  Mar 15 14:56:31 fat-man systemd[22162]: my-app.service: Failed at step CHDIR spawning /home/deployer/.rvm/gems/ruby-2.2.1@my-app/bin/bundle: No such file or directory
  Mar 15 14:56:31 fat-man systemd[1]: my-app.service: Main process exited, code=exited, status=200/CHDIR
  Mar 15 14:56:31 fat-man systemd[1]: my-app.service: Control process exited, code=exited status=200
  Mar 15 14:56:31 fat-man systemd[1]: my-app.service: Unit entered failed state.
  Mar 15 14:56:31 fat-man systemd[1]: my-app.service: Failed with result 'exit-code'.
  </code></pre>
  
  <p>What could be the problem?</p>