Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


How to start shadowsocks-go on boot?
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

How to start shadowsocks-go on boot?

geodirkgeodirk Member
edited May 2014 in Help

I just installed shadowsocks-go (not the standard version of shadowsocks) in a VPS and it works great as long as I'm logged in with PuTTY. As soon as I shut down, poof, the program drops out of memory. So I found out that if you do a little magic, you can get it to run in the background and I put that in a script. So now, how can I configure the server to execute the script on startup and run the program in the background?

CentOS 5.10

Install path: /root/go/bin/shadowsocks-server

Config file in same folder.

The script that starts the program:

#!/bin/bash
cd ~/go/bin/
./shadowsocks-server > log &

That runs the service when I'm logged in with Putty and puts it in the background. To try to get it to run on boot, I've added this line to the /etc/rc.d/rd.local file:

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
sh /root/startSocks.sh

But that doesn't seem to start it on boot and I'm still forced to log in and hand start it with my script. Any ideas of where is my mistake?

Comments

  • You need to run it in either a screen session, or with nohup. Preferably a screen session. Otherwise, it'll lose its terminal and die.

    Thanked by 1geodirk
  • You could try Upstart:

    shadowsocks-go.conf

    start on filesystem and started networking
    stop on shutdown
     
    author "Silvenga"
    description "Quick Shadowsocks-go Upstart Script"
    version "0.1"
     
    respawn
    respawn limit 5 30
     
    env name=shadowsocks-server
    env uid=root
    env gid=root
    env daemon=/root/shadowsocks-server
     
    script
        exec start-stop-daemon --start --make-pidfile --pidfile /var/run/$name.pid --name $name -c $uid:$gid -x $daemon >> /var/log/upstart/$name.log 2>&1
    end script
    

    Install as an Upstart job on your system (should be on CentOS by default). Then reboot.

    The script starts when networking and the file system is ready (prevents crashing on some systems).

    To manually control it just use the service commands:

    • service shadowsocks-go start
    • service shadowsocks-go stop
    • service shadowsocks-go restart
    • service shadowsocks-go status

    A resource incase you run into trouble and need to know what to Google :P

    http://www.openlogic.com/wazi/bid/281586/How-to-write-CentOS-initialization-scripts-with-Upstart

    Thanked by 1geodirk
Sign In or Register to comment.