Discourse: Some tips and tricks (logging), adding new plugins, debugging

Discourse: Some tips and tricks (logging), adding new plugins, debugging

First thing you have to do is log-in to your server using ssh and going to the discourse installation path:

# login in to your ssh account
ssh youraccount@yourip.com
cd /var/discourse

If you need to see the rails logs and see what is doing discourse the commands bellow are what you’re looking for:

# connecting to the rails application
./launcher ssh app
cd /var/www/discourse
#starts all the logs in console
tail -f log/*.log


Start a new rails console to look into the discourse database:

# connecting to the rails application
./launcher ssh app
cd /var/www/discourse
# connecting to the rails application
RAILS_ENV=production bundle exec rails c

Adding a new plugin to your discourse installation

# Search your app.yml file
# in my case the file is located in /var/discourse/containers/app.yml
# add your plugin for example for me I have added a new plugin that I built and the following code it is how it looks like:
hooks:
  after_code:
    - exec:
        cd: $home/plugins
        cmd:
          - mkdir -p plugins
          - git clone https://github.com/discourse/docker_manager.git
          - git clone https://github.com/heridev/discourse-endpoint.git 

Reload discourse for example after that you added a new plugin:

ssh youraccount@yourip.com
cd /var/discourse
./launcher rebuild app

Structure for new plugins, create new discourse settings(values), locales/translations accessible from javascript/controllers/backend/frontend

https://gist.github.com/heridev/de88627c9c519b4a0b42

The following it is a plugin that I created to add an extra endpoint/api route to return specific information from discourse database

https://github.com/heridev/discourse-endpoint
No Comments

Post A Comment