Tuesday, December 18, 2018

gohttpserver go

$$$$$$$$$$$$$$$$$$$$$$$ quick restart gohttpserver $$$$$$$$$$$$$$$$$$$$$

//start supervisord
sudo su
cd /home/hoogw/gowork/src/github.com/codeskyblue/gohttpserver

supervisord -c supervisord.conf



//stop supervisord
// first switch to root user
sudo su
cd /home/hoogw/gowork/src/github.com/codeskyblue/gohttpserver



https://stackoverflow.com/questions/14479894/stopping-supervisord-shut-down
ps -ef | grep supervisord
kill -s SIGTERM 15923( only one number a line , line with 2 number are NOT right)
http://supervisord.org/running.html#signals



$$$$$$$$  end   $$$$$$$$$$$$$$$ quick restart gohttpserver $$$$$$$$$$$$$$$$$$$$$










****************************************************************


https://github.com/indexzero/http-server

linux


putty:

// first switch to root user
sudo su

// install
npm install http-server -g


// run
http-server ./fileRestAPI



**********************************************




go http server


C:\Users\engcid299\go\src\github.com\codeskyblue\gohttpserver>gohttpserver -r ./testdata --port 8000 --upload --delete --cors



//install go linux
https://tecadmin.net/install-go-on-centos/





wget https://dl.google.com/go/go1.10.1.linux-amd64.tar.gz

tar -xvf go1.10.1.linux-amd64.tar.gz

//Setup Go Environment


// first switch to root user
sudo su


export GOROOT=/home/hoogw/go

export GOPATH=/home/hoogw/gowork

export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
--------------------------------------------------


install gohttpserver

mkdir gowork
cd gowork

// this will create bin, src folder
go get -v github.com/codeskyblue/gohttpserver

cd src/github.com/codeskyblue/gohttpserver

go build

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

// copy pdf file to gowork

// DO not use commmend below, instead use WinSCP (download and install, no admin privilage needed)

//cp -r /home/hoogw/fileRestAPI /home/hoogw/gowork/src/github.com/codeskyblue/gohttpserver
//cp -r /home/hoogw/gowork/src/github.com/codeskyblue/gohttpserver/testdata/config.yml /home/hoogw/gowork/src/github.com/codeskyblue/gohttpserver/fileRestAPI


when start WinSCP, must login as root user, by
https://stackoverflow.com/questions/34798936/how-to-run-sudo-command-in-winscp-to-transfer-files-from-windows-to-linux/53787591#53787591



login screen, left panel, choose new site, right panel,  file protocol:  choose SCP,   click advanced

left panel, choose SCP/shell, right panel, Shell: type 'sudo su -'


There is an option in WinSCP that does exactly what you are looking for:

enter image description here
enter image description here



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

Delete build.sh file, no need.


Modify main.go

// run it, Must use ./, to use new developing version.  otherwise, it will use old installed version
// always is 8000 for https, no http
./gohttpserver -r ./fileRestAPI --cors
./gohttpserver -r ./fileRestAPI --port 8000 --upload --delete --cors






// run it as background

// create file, save to where you call gohttpserver folder.

// create config file


// use nano to edit, or you can create it at windows, use winSCP to copy over
nano supervisord.conf

// type content
[program:supervisord]
command=./gohttpserver -r ./fileRestAPI  --cors

If you want to save the changes you've made, press Ctrl + O.
To exit nano, type Ctrl + X. If you ask nano to exit from a modified file, it will ask you if you want to save it.
Just press N in case you don't, or Y in case you do. It will then ask you for a filename.
Just type it in and press Enter.



//start supervisord
sudo su
cd /home/hoogw/gowork/src/github.com/codeskyblue/gohttpserver

supervisord -c supervisord.conf



//stop supervisord
// first switch to root user
sudo su
cd /home/hoogw/gowork/src/github.com/codeskyblue/gohttpserver



https://stackoverflow.com/questions/14479894/stopping-supervisord-shut-down
ps -ef | grep supervisord
kill -s SIGTERM 15923( only one number a line , line with 2 number are NOT right)
http://supervisord.org/running.html#signals




ps -ef | grep supervisord
You will get some pid of supervisord just like these

root 2641 12938 0 04:52 pts/1 00:00:00 grep --color=auto supervisord

root 29646 1 0 04:45 ? 00:00:00 /usr/bin/python /usr/local/bin/supervisord

if you get output like that, your pid is the second one ( with only one number, it will not change if you run again again, but other number are changing. then if you want to shut down your supervisord you can do this

kill -s SIGTERM 29646






===================================

localhost run gohttpserver


./gohttpserver -r ./fileRestAPI --port 8000 --cors

go build



=========================================

supervisord.conf
[unix_http_server]
file=/tmp/supervisor.sock ; path to your socket file


[supervisord]
;logfile=/var/log/supervisord/supervisord.log ; supervisord log file
;logfile_maxbytes=50MB ; maximum size of logfile before rotation
;logfile_backups=10 ; number of backed up logfiles
;loglevel=error ; info, debug, warn, trace
;pidfile=/var/run/supervisord.pid ; pidfile location
nodaemon=false ; run supervisord as a daemon
minfds=1024 ; number of startup file descriptors
minprocs=200 ; number of process descriptors
user=root ; default user
;childlogdir=/var/log/supervisord/ ; where child log files will




[program:fileRestAPI]
command=./gohttpserver -r ./fileRestAPI --cors
;command=gohttpserver -r ./fileRestAPI --port 8000 --upload --delete --cors


[supervisorctl]
serverurl=unix:///tmp/supervisor.sock ; use a unix:// URL for a unix socket

















Friday, December 7, 2018

q2a remove tab, most voted, search bar


http://technosmarter.com/qa/212/how-to-increase-maximum-content-length-is-12000-characters-in-q2a


How to increase maximum content length is 12000 characters in Q2A ?


You are using Question2answer (Q2A) QA base application. Under the Q2A application answer characters already set to 12000. You can increase the length of answer characters through the maximum.php  file from the DB folder. 
I understand your concern. Yes, you can increase the length of characters. 
Question2answer allows you to customize the QA application. 
Increase maximum content length is 12000 characters in Q2A application
Navigate to the path - 
qa/qa-include/db/maxima.php
Edit the maxima.php file and find below code - 
'QA_DB_MAX_CONTENT_LENGTH' => 12000,
change to 
'QA_DB_MAX_CONTENT_LENGTH' => 18000,

Now save your Q2A file and execute. You will not get the error "Maximum length is 12000 characters" 






=================================================

remove search bar, and side panel


C:\Apache24\htdocs\cleargov1\qa-theme\Donut-theme\qa-donut-layer.php

1) comment out this line

if ( !$this->donut_do_hide_sidebar() ) {

// remove side panel and search bar
// $this->sidepanel();
}



2) adjust the width

function main()
{
$content = $this->content;

// no right side panel, no search bar in right side panel.
// $width_class = ( $this->donut_do_hide_sidebar() && $this->template != 'admin' ) ? 'col-xs-12' : 'qa-main col-md-9 col-xs-12 pull-left';
$width_class = ( $this->template != 'admin' ) ? 'col-xs-12' : 'qa-main col-md-9 col-xs-12 pull-left';




..................................................................................................

change page title, recent to empty,

C:\Apache24\htdocs\cleargov1\qa-include\lang\qa-lang-main.php


'nav_most_recent' => 'Recent',

change to


'nav_most_recent' => '',
-----------------------------------------------------------------


'recent_qs_as_title' => '', //'Recent ',

'recent_qs_title' => '', //'Recent ',







...............................................................................................

remove tab, hot, most answered

comment out below

C:\Apache24\htdocs\cleargov1\qa-include\app\q-list.php

/*
'hot' => array(
'label' => qa_lang('main/nav_hot'),
'url' => qa_path_html($request, array('sort' => 'hot')),
),
         */



/*
'votes' => array(
'label' => qa_lang('main/nav_most_votes'),
'url' => qa_path_html($request, array('sort' => 'votes')),
),

            */




/*
'answers' => array(
'label' => qa_lang('main/nav_most_answers'),
'url' => qa_path_html($request, array('sort' => 'answers')),
),

            */

remove most viewed page by comment out:

/*
        'views' => array(
            'label' => qa_lang('main/nav_most_views'),
            'url' => qa_path_html($request, array('sort' => 'views')),
        ),
*/