Bitcoin Forum
November 04, 2024, 06:11:52 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: 1 BTC for basic linux info - How to auto start namecoind and pushpoold  (Read 3085 times)
DavinciJ15 (OP)
Hero Member
*****
Offline Offline

Activity: 780
Merit: 510


Bitcoin - helping to end bankster enslavement.


View Profile WWW
August 07, 2011, 05:24:50 AM
Last edit: August 16, 2011, 06:12:33 PM by DavinciJ15
 #1

So I googled
found many ways to get things started but none of them worked.

Let me show you one way that I though should be basic and work...

I opened up the file
/etc/rc.local
Looks like this...
Code:
#!/bin/sh
#
# This script is executed at the end of each multiuser runlevel.

/home/bitcoinpool/namecoin/namecoind -daemond &
/home/bitcoinpool/pushpool/pushpoold --config=/home/bitcoinpool/pushpool/server.json &

Exit 0

When I reboot nothing.

Please help and get paid in full!
jondecker76
Full Member
***
Offline Offline

Activity: 238
Merit: 100


View Profile
August 07, 2011, 06:07:01 AM
 #2

What distro are you using?  I ask because some distros use /etc/rc.d/rc.local.

Was /etc/rc.local already there and you added to it, or did you create it yourself?

You could also do some simple debugging to see if your script is ever being executed. Something simple like:

Code:
echo "Yep, it executed!" > /home/bitcoinpool/debug.txt

Then after a reboot you can see if it made the debug.txt.file

RollerBot Advanced Trading Platform
https://bitcointalk.org/index.php?topic=447727.0
BTC Donations for development: 1H36oTJsi3adFh68wwzz95tPP2xoAoTmhC
jondecker76
Full Member
***
Offline Offline

Activity: 238
Merit: 100


View Profile
August 07, 2011, 06:36:16 AM
 #3

One other thing to mention.  Some scripts need to run as the correct user (so that they know where their hidden data directory is).  If I were you, I would change the script to look like the example below, so that they execute as the correct user (and not as root):

Code:
#!/bin/sh
#
# This script is executed at the end of each multiuser runlevel.

su bitcoinpool -c /home/bitcoinpool/namecoin/namecoind -daemond &
su bitcoinpool -c /home/bitcoinpool/pushpool/pushpoold --coinfig=/home/bitcoinpool/pushpool/server.json &

Exit 0

RollerBot Advanced Trading Platform
https://bitcointalk.org/index.php?topic=447727.0
BTC Donations for development: 1H36oTJsi3adFh68wwzz95tPP2xoAoTmhC
Bitsky
Hero Member
*****
Offline Offline

Activity: 576
Merit: 514


View Profile
August 07, 2011, 07:00:56 AM
 #4

To capture all output (stdout+stderr), you can append ">> /var/log/bitcoinpool.log 2>&1".
Also, check your standard logs (messages, cron) for additional error messages.

In most cases such scripts fail because of relative paths. Cron has a different environment.

Bounty: Earn up to 68.7 BTC
Like my post? Feel free to drop a tip to 1BitskyZbfR4irjyXDaGAM2wYKQknwX36Y
Bitsky
Hero Member
*****
Offline Offline

Activity: 576
Merit: 514


View Profile
August 07, 2011, 07:09:06 AM
 #5

Also...

I assume you don't mean "coinfig", but "config"

Bounty: Earn up to 68.7 BTC
Like my post? Feel free to drop a tip to 1BitskyZbfR4irjyXDaGAM2wYKQknwX36Y
nodemaster
Full Member
***
Offline Offline

Activity: 176
Merit: 100



View Profile WWW
August 07, 2011, 07:34:27 AM
 #6

Using rc.local you "fire-and-forget" the daemon. UNIX style is to have an init script which you can use in order to start, stop and restart daemons. Furthermore the init process will start the daemons for you if you linked the init script to the appropriate runlevel(s) and stops them properly if you reboot/halt the server. With this knowledge you should have a look at this thread:

http://bitcointalk.org/?topic=965.0

and adapt it to your needs. It should help you doing it the "right" way. Do the same for pushpoold. If you like you can tip the original author.
error
Hero Member
*****
Offline Offline

Activity: 588
Merit: 500



View Profile
August 07, 2011, 06:40:00 PM
 #7

Also, "daemon" is misspelled.

3KzNGwzRZ6SimWuFAgh4TnXzHpruHMZmV8
antares
Hero Member
*****
Offline Offline

Activity: 518
Merit: 500


View Profile
August 07, 2011, 09:39:23 PM
 #8

So I googled
found many ways to get things started but none of them worked.

Let me show you one way that I though should be basic and work...

I opened up the file
/etc/rc.local
Looks like this...
Code:
#!/bin/sh
#
# This script is executed at the end of each multiuser runlevel.

/home/bitcoinpool/namecoin/namecoind -daemond &
/home/bitcoinpool/pushpool/pushpoold --coinfig=/home/bitcoinpool/pushpool/server.json &

Exit 0

When I reboot nothing.

Please help and get paid in full!


Heres what you need:
create the following script:
Quote
#!/bin/sh
# Starts and stops namecoin + pushpool
#


case "$1" in
start)
       /home/bitcoinpool/namecoin/namecoind -daemon -server
       /home/bitcoinpool/pushpool/pushpoold --config=/home/bitcoinpool/pushpool/server.json &
      
;;

stop)
   
   killall namecoind pushpoold
;;

restart)
     $0 stop
     $0 start
;;

*)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
esac

save the script under /etc/init.d/somenameyoucanchooseyourself
now, make the script executable:
chmod +x /etc/init.d/somenameyoucanchooseyourself

if you use a debian like system(ie debian, ubuntu etc), you can enable this script to run at boot using:
update-rc.d somenameyoucanchooseyourself defaults
twobits
Sr. Member
****
Offline Offline

Activity: 574
Merit: 250



View Profile
August 08, 2011, 06:11:28 PM
Last edit: August 08, 2011, 07:13:47 PM by twobits
 #9

So I googled
found many ways to get things started but none of them worked.

Let me show you one way that I though should be basic and work...

I opened up the file
/etc/rc.local
Looks like this...
Code:
#!/bin/sh
#
# This script is executed at the end of each multiuser runlevel.

/home/bitcoinpool/namecoin/namecoind -daemond &
/home/bitcoinpool/pushpool/pushpoold --coinfig=/home/bitcoinpool/pushpool/server.json &

Exit 0

When I reboot nothing.

Please help and get paid in full!


Linux does not define the runlevel start up scripts,  depends on the specific userland as to how that is set up. Just which init set up is being used?   What are you running specifically?

Also, the above runs everything as root,  not a great idea.   I would  run namecoid as its own user, probably in a chrooted jail.

In any case, a lot of Linux set up use vixie cron... in that case create a user
for running this ( myncduser or whatever).  Add them to cron.allow if need be.

# crontab -u myncduser  -e

then add the line

@reboot /home/bitcoinpool/namecoin/namecoind -daemond


or better yet,  put it in a script that can restart it if it fails,   actually  if this is for production use, look into something like daemontools or runit  iinstead.

█████                █████      ███████             
█████                ███    █████████████       
█████                ██  █████████████████   
█████                █  ██████              ██████ 
█████                    ████                      ████ 
█████████████  █████                        ████
█████████████  █████                        ████
█████████████  █████                        ████
█████                    █████                             
█████                █  ██████              ███████
█████                ██  ███████████    █████ 
█████                ███    █████████    ████   
█████                █████      ███████    ██
███
███
███
███
███
███
███
███
███
HyperQuant.net
Platform for Professional Asset Management
███
███
███
███
███
███
███
███
███
WhitePaper
One-Pager
███
███
███
███
███
███
███
███
███
Telegram 
Facebook
Twitter
Medium
███
███
███
███
███
███
███
███
███
███
███
███
███
███
███
███
███
███
█████                █████      ███████             
█████                ███    █████████████       
█████                ██  █████████████████   
█████                █  ██████              ██████ 
█████                    ████                      ████ 
█████████████  █████                        ████
█████████████  █████                        ████
█████████████  █████                        ████
█████                    █████                             
█████                █  ██████              ███████
█████                ██  ███████████    █████ 
█████                ███    █████████    ████   
█████                █████      ███████    ██
kseistrup
Hero Member
*****
Offline Offline

Activity: 566
Merit: 500


Unselfish actions pay back better


View Profile WWW
August 08, 2011, 06:52:29 PM
 #10


or better yet,  put it in a script that can restart it if it fails,   actually  if this is for production use, look into something like daemontools or runit  iinstead.

Some linuxes (ubuntu comes to mind) use upstart, so all you have to do is drop a properly formed script in /etc/init.  E.g.:

Code:
# bitcoind

description "Keep bitcoind in the air"

start on (filesystem
          and runlevel [2345]
          and started rsyslog
          and net-device-added INTERFACE=eth0)

stop  on (shutdown
          or runlevel [!2345])

pre-start script
  /usr/bin/logger -t upstart starting bitcoind
end script

post-start script
  /usr/bin/logger -t upstart started bitcoind
end script

env LANG=C
env LC_ALL=C
env HOME=/var/lib/bitcoin

export LANG
export LC_ALL
export HOME

chdir /var/spool/bitcoin
umask 0077
nice 10

kill timeout 45

script
  exec /usr/bin/sudo -H -u bitcoin \
       /usr/local/sbin/bitcoind -datadir=/var/spool/bitcoin -server
end script

respawn

pre-stop script
  /usr/bin/logger -t upstart stopping bitcoind
  exec /usr/local/sbin/bitcoind stop
end script

post-stop script
  /usr/bin/logger -t upstart stopped bitcoind
end script

# eof

(The script make assumptions about where to find bitcoind, what user to run as, wich network interface to use, etc.)

Cheers,

Klaus Alexander Seistrup
DavinciJ15 (OP)
Hero Member
*****
Offline Offline

Activity: 780
Merit: 510


Bitcoin - helping to end bankster enslavement.


View Profile WWW
August 10, 2011, 06:22:34 PM
 #11

Thanks for all the solutions I will try them all and give the reward to the first person that got it right.  I am 100% sure that syntax errors will cause it to fail ether by me or in your comment.

BTW I am using ubuntu server 11.04.

DavinciJ15 (OP)
Hero Member
*****
Offline Offline

Activity: 780
Merit: 510


Bitcoin - helping to end bankster enslavement.


View Profile WWW
August 16, 2011, 07:12:21 PM
 #12

I have tried every single option none of them work I am missing stuff like what user run it under or whatever I'll have to figure it out.

The /etc/init.d/myscriptname was helpful as I can manually stop and start it.  Thanks!
Bitsky
Hero Member
*****
Offline Offline

Activity: 576
Merit: 514


View Profile
August 16, 2011, 07:31:49 PM
 #13

Haven't used Ubuntu that often, but if I remember correctly you can have a service start automatically at boot with something like "update-rc.d myscriptname defaults" as root.
Or you can symlink to the script in init.d from rc3.d/S99myscriptname (don't forget that you probably also need to symlink rc1.d/K99myscriptname).
Don't forget to look into logs for error messages.

Bounty: Earn up to 68.7 BTC
Like my post? Feel free to drop a tip to 1BitskyZbfR4irjyXDaGAM2wYKQknwX36Y
DavinciJ15 (OP)
Hero Member
*****
Offline Offline

Activity: 780
Merit: 510


Bitcoin - helping to end bankster enslavement.


View Profile WWW
August 16, 2011, 07:54:37 PM
 #14

Haven't used Ubuntu that often, but if I remember correctly you can have a service start automatically at boot with something like "update-rc.d myscriptname defaults" as root.
Or you can symlink to the script in init.d from rc3.d/S99myscriptname (don't forget that you probably also need to symlink rc1.d/K99myscriptname).
Don't forget to look into logs for error messages.


I did the "update-rc.d myscriptname defaults" as root rebooted and nothing started.

Just so you know I have no idea where the logs are.

Bitsky
Hero Member
*****
Offline Offline

Activity: 576
Merit: 514


View Profile
August 16, 2011, 08:54:18 PM
 #15

Hm, can you post the script you use?

Did you get any output when you did the update-rc.d?
Undo the previous: update-rc.d myscriptname remove
Set runlevels manually: update-rc.d myscriptname start 13 stop 06
Look into /etc/rc3.d/ to see if there's a symlink to your /etc/init.d/myscriptname

Logs should go into /var/log/. Usually, there's messages, boot, syslog or something similar which might contain some information about why the service start fails. dmesg perhaps too.
I'm running out of ideas sadly though, since Ubuntu isn't my preferred Linux distro. Oh, and you are in runlevel 3, right? Check with "who -r".

And "/etc/init.d/myscriptname start" works just fine when you do it manually? What user are you when doing that? Root?

Bounty: Earn up to 68.7 BTC
Like my post? Feel free to drop a tip to 1BitskyZbfR4irjyXDaGAM2wYKQknwX36Y
DavinciJ15 (OP)
Hero Member
*****
Offline Offline

Activity: 780
Merit: 510


Bitcoin - helping to end bankster enslavement.


View Profile WWW
August 16, 2011, 10:35:00 PM
 #16

Hm, can you post the script you use?

Did you get any output when you did the update-rc.d?
Undo the previous: update-rc.d myscriptname remove
Set runlevels manually: update-rc.d myscriptname start 13 stop 06
Look into /etc/rc3.d/ to see if there's a symlink to your /etc/init.d/myscriptname

Logs should go into /var/log/. Usually, there's messages, boot, syslog or something similar which might contain some information about why the service start fails. dmesg perhaps too.
I'm running out of ideas sadly though, since Ubuntu isn't my preferred Linux distro. Oh, and you are in runlevel 3, right? Check with "who -r".

And "/etc/init.d/myscriptname start" works just fine when you do it manually? What user are you when doing that? Root?
Thanks.
For your help if we get it going I'll pay you the BTC.
Anyhow I'm not in front of the computer right now but to test, and verify all the things you ask. However i can tell you that "/etc/init.d/myscriptname start" works just fine and I am happy about that.  But if I run it as a user and not root it fails as namcoind try's to read the data from /home/username/.namecoin instead of /root/.namecoin

Bummer. As chown to the /root/.namecoin does not work.  I guess I have to do some sort of linking of the folders. 
Bitsky
Hero Member
*****
Offline Offline

Activity: 576
Merit: 514


View Profile
August 16, 2011, 11:06:41 PM
 #17

Some things that come to mind:
- perhaps namcoind has an option to specify the data directory (bitcoin has, I'm using that)
- symlink (ln -s) or hardlink (mount -o bind) those directories (hardlinks need to go into /etc/fstab too iirc)


Bounty: Earn up to 68.7 BTC
Like my post? Feel free to drop a tip to 1BitskyZbfR4irjyXDaGAM2wYKQknwX36Y
DavinciJ15 (OP)
Hero Member
*****
Offline Offline

Activity: 780
Merit: 510


Bitcoin - helping to end bankster enslavement.


View Profile WWW
September 01, 2011, 11:44:06 PM
 #18

Back to the restart problem that has not been fixed yet.

Here is a copy of my script... (remember I am not a linux user in fact the last 30 days it the most I have used linux in my whole life.)

Code:
#!/bin/sh
# Starts and stops namecoin & pushpool & blkmond
#


case "$1" in
start)
        echo ""
        echo "Starting namecoind and pushpool"
        echo ""
       /home/ubuntu/namecoin/namecoind -daemon -server
        sleep 1
       /home/ubuntu/pushpool/pushpoold --config=/home/ubuntu/pushpool/server.json
        screen -dmS blkmond /home/ubuntu/pushpool/blkmond /home/ubuntu/pushpool/blkmond.conf
        $0 view

;;

stop)
   echo ""
   echo "Killing pushpoold then Stoping namecoin"

   killall pushpoold
   killall blkmond
   /home/ubuntu/namecoin/namecoind stop
;;

restart)
     $0 stop
     sleep 4
     $0 start
;;

view)
        ps -e | grep namecoind
        ps -e | grep pushpoold
        ps -e | grep blkmond
;;


*)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
esac

This (/etc/init.d/namecoin start;) needs to be executed as root under ubuntu 11.04 this should be easy PLEASE help.  I have to ask since I have and major issues everywhere else and was able to resolve it but this eludes me?  WTF?

BTW the script works.
DavinciJ15 (OP)
Hero Member
*****
Offline Offline

Activity: 780
Merit: 510


Bitcoin - helping to end bankster enslavement.


View Profile WWW
September 01, 2011, 11:49:14 PM
Last edit: September 02, 2011, 12:13:03 AM by DavinciJ15
 #19

Why did this not work?

Code:
update-rc.d namecoin defaults;

running it again gives me this...

Code:
 update-rc.d namecoin defaults
update-rc.d: warning: /etc/init.d/namecoin missing LSB information
update-rc.d: see <http://wiki.debian.org/LSBInitScripts>
 System start/stop links for /etc/init.d/namecoin already exist.

Reboot gives me JAKE STINK ALL.  WTF?

running as su manually
/etc/init.d/namecoin start;
give me what I want the start up to do!


BTW pushpoold is the only thing that is running after reboot.
jfreak53
Sr. Member
****
Offline Offline

Activity: 298
Merit: 252



View Profile WWW
September 02, 2011, 12:10:57 AM
 #20

PM me and for 1.5 BTC I can work on it personally or have one of our techs do it since we run those services all the time on our servers and are used to them. (1.5 because of the low price of the BTC right now)

What we can also do is run a screen session so you can watch how we fix it in real-time so you know exactly what we did also.

Just would need SSH login information for the server in question and root access.

█ █ microtronixdc.com - Performance VPS, Dedicated Servers, Colocation, Full-Rack options!
Massive Network Bandwidth options with Fiber throughout! Always-On DDoS Mitigation for all traffic!
Pages: [1] 2 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!