Saturday, April 13, 2019

ipfs auto restart


https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html#//apple_ref/doc/uid/10000172i-SW7-BCIEDDBJ



https://medium.com/@chetcorcos/a-simple-launchd-tutorial-9fecfcf2dbb3


this sh file is locate at :/Users/sirius/ipfs_auto_restart.sh

to run this file once:
     sh /Users/sirius/ipfs_auto_restart.sh

create this file:

   sudo vim /Users/sirius/ipfs_auto_restart.sh

then, copy past below script
then
  1. Open the terminal application in Linux or Unix
  2. Next, open a file in vim / vi, type: vim filename
  3. To save a file in Vim / vi, press Esc key, type :w and hit Enter key
  4. One can save a file and quit vim / Vi by pressing Esc key, type :x and hit Enter key

---------------------


#!bin/bash
#Start  only if it is not running
SERVICE="ipfs"
if pgrep -x > "$SERVICE" >/dev/null
then
 "$SERVICE is running"
else
 ipfs daemon
 echo "$SERVICE stopped, but re-started...."
fi


------------------

========  create a plist file =================

sudo vim /Library/LaunchDaemons/com.ipfs.auto.restart.plist

copy below xml and past, then exit

  1. Open the terminal application in Linux or Unix
  2. Next, open a file in vim / vi, type: vim filename
  3. To save a file in Vim / vi, press Esc key, type :w and hit Enter key
  4. One can save a file and quit vim / Vi by pressing Esc key, type :x and hit Enter key



ProgramArguments              touch         /tmp/helloworld    









    Label
    com.ipfs.daemon
        ProgramArguments

                 
              sh
              /Users/sirius/ipfs_auto_restart.sh
      

    KeepAlive
        StartInterval   
    10











    Label
    com.ipfs.daemon
    Program
    /Users/sirius/ipfs_auto_restart.sh
    KeepAlive
   

    StartInterval   
    10





 ...............................................................................
Before run
                          ipfs add -r xxxx

must close all ipfs daemon from task manager

clean close all process.

 get error:

siriuss-mini:~ sirius$ ipfs add -r /Volumes/original-1/fileRestAPI/Los_Angeles_County_Land_Records
Error: cannot connect to the api. Is the deamon running? To run as a standalone CLI command remove the api file in `$IPFS_PATH/api`


you have to go d:\ipfs_repo
to delete api file and repo.lock file,
because when you force quit ipfs desktop, those 2 file left un-closed,
you must manually delete them.

--------------------------------------------------------------------------------------------------------------------

No comments: