Monday, 6 August 2018

Deploy Your .Net-Core-service to run as Service in Ubuntu



step 1:  publish the code

step 2: > sudo nautilus -- to open file explorer in ubuntu
   > paste the code into /opt/ServiceFolder

step 3: > cd /etc/systemd/system

step 4: > gedit syslog.service &

step 5: > copy and paste the same content into a new file

step 6: > you will find 3 section
[Unit]

[Service]

[Install]

step 7: > [Unit]
       Description=Your Service Name

Step 8: > [Service]
                ExecStart=/usr/bi/dotnet /opt/ServiceFolder/service.dll
        Restart=always

(we need dotnet command to lunch application, and its path, you can find by using [which dotnet] from terminal )

Step 9: > [Install]
       WantedBy=default.target

(The dictation processor doesn't have any special need here, so you can just specify the default target.)


step 10: > then save it into /etc/systemd/system folder with proper name : such as myservice-processor.service

Step 11: > you can now use systemd to control your service.

step 12: > systemd command

1) >systemctl status myservice-processor
  2) >q - to quit from command
3) >sudo systemctl start myservice-processor
4) >sudo systemctl status myservice-processor


step 13: > lets give the journalctl command a try. use the -u switch to pass it the name of our unit or service which is myservice-processor, and use the -f switch to follow the journal live.

> sudo journalctl -u myservice-processor -f


step 14: Now, since you defined in the service file, how the service would start on boot, but it won't actually do so untill you pass enable systemctl for this unit. go ahead and do it

> sudo systemctl enable myservice-processor


(you notice that enabling creates a symlink. by doing so, systemd hooks the myservice-processor into the system init.


step 15: > now if you restart your machine , and check the service status again the myservice-processor is already running.


 


Monday, 23 April 2018

SSH Tunneling - Deep Understanding





Step 1: SSH Command

            SSH -i ./.ssh/sj03 user@domain.com

Step 2: Add -N to Network Port forward

            SSH -i ./.ssh/sj03 user@domain.com -N

Step 3:  Add  -L if tunnel starts on Local

            SSH -i ./.ssh/sj03 user@domain.com -N -L 8888

Step 4: Add -R if tunnel starts on Remote
         
            SSH -i ./.ssh/sj03 user@domain.com -N -R 80

Step 5: Open local 8510 port and forward to <remote-server-ip-you-want-to-connect> on port 22:

            SSH -i ./.ssh/sj03 user@domain.com -N -L 8510:<remote-server-ip-you-want-to-connect>:22

Step 6: Now, local port is open , connect your server

            SSH -i ./.ssh/sj03 user@localhost -p 8510




Monday, 1 January 2018

Dotnet Core development starting setup in ubunto

steps to start dotnet core develpment in ubunto:

1.Add the dotnet product feed

    a) Register the trusted Microsoft signature key:
   
        $ curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
        $ sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg


    b) Register the Microsoft Product feed

        $ sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" > /etc/apt/sources.list.d/dotnetdev.list'

2. Install .NET SDK

    $ sudo apt-get update
    $ sudo apt-get install dotnet-sdk-2.0.2

3.Create your app
   
    $ dotnet new console -o myApp
    $ dotnet run

4.Get an editor

    a) download .deb file from https://code.visualstudio.com/
    b) sudo apt install <<path of .deb file>>