How to auto restart a crashed app?
Open your terminal and type as
gedit autostart.sh
then paste this code as it as
#!/bin/bash
while true
do
if [ ! `pgrep docky` ] ; then
/usr/bin/autorestart1.sh
fi
sleep 30
done
save it & close.
Then again in the terminal type as
sudo gedit /usr/bin/autostart1.sh
and paste
cd /usr/bin/
docky
save & close.
thats it now onwards. your application will be autostart after the crash,:)
Credit goes to Ubuntuforums
Related videos on Youtube
ottercoder
Updated on September 18, 2022Comments
-
ottercoder over 1 year
I'm trying to implement Angular Interceptor for Exceptions. For one at least. I have a token and when it old enogh backend throws
TokenAlmostExpired exception
. This exception containserrorCode = 101
. In the interceptor I'm checking that code is 101 and then I need to sendPOST request
to backend's/refresh endpoint
so I could refresh token..factory('errorInjector',['$injector', function ($q, $injector) { var vm = this; var errorInjector = { 'response': function (response) { console.log(response); return response; }, 'responseError': function (rejection) { if (JSON.stringify(rejection.data.errorCode) === JSON.stringify(101)) { vm.getRefreshToken(); } return $q.reject(rejection); } }; return errorInjector; }]);
and
.config(['$httpProvider', function ($httpProvider) { $httpProvider.interceptors.push('errorInjector'); }]);
$http
But there's a problem at interceptor level, that I can't just give it dependency on
$http
, because there'sCircular dependency found: $http <- errorInjector <- $http <- $templateFactory <- $view <- $state
$scope
And I can't put
getRefreshToken()
function to$scope
, because $scope dependency also gives 'Circular dependency'.$Injector
var http = $injector.get('$http');
doesn't work as well, and gives me erorr.
So how can I catch exception in interceptor and then do a $http request from there?
-
Callum Linington almost 8 yearsYou may want to consider firing off an event, and picking it up in a service and doing the execution from there
-
Callum Linington almost 8 yearsDon't use rootscope, create your own event aggregator...
-
el vis almost 8 yearsCan you show full errorInjector code? It seems that it is not full implementation.
-
Callum Linington almost 8 yearsWe don't need full errorInjector code, there is enough there
-
el vis almost 8 yearsI do not think so. It has $injector injected that should be used to avoid circural dependency .
-
Callum Linington almost 8 yearsUsing
$injector
is a code smell to me -
Callum Linington almost 8 yearsHere is an event aggregator pattern implementation if you want a full on example with your code just ask
-
ottercoder almost 8 years@CallumLinington I've never done anything with event, so I'd really like to get some help on that, thanks. As long as I understand it supposed to be easy .broadcast("something), .subscribe('something), right?
-
Callum Linington almost 8 yearsYeah, if you look at my plnker it should be fairly obvious to what is going on
-
ottercoder almost 8 years@CallumLinington, not really there's a lot of letters that I don't get. What is "t" and "ev", for instance?
-
el vis almost 8 years@ottercoder if you do not understand @CallumLinington code it seems that you do not understant DI in angular, thats why you have
'$injector', function ($q, $injector)
which should be'$q', '$injector', function ($q, $injector)
and thats probably your problem here -
Callum Linington almost 8 yearsYeah, would agree with @pawlakppp on this
-
ottercoder almost 8 yearsIf I'd understand Angular completely, I would'nt need a help at all. But I've found a solution. I'm putting function from service to $rootScope and calling it as a promise.
$q.get('$rootScope').vmRT.getRefreshToken();
-
-
Blaine about 8 yearshow can I implement this to function the same way if a user quits the application? And is "autostart1.sh" supposed to be named "autorestart1.sh" as per previous file?
-
ottercoder almost 8 years
Circular dependency found: $http <- errorLauncher <- httpInterseptor <- $http <- $templateFactory <- $view <- $state
:/ -
Alexandr Fedoseev almost 8 yearstry the $emit from error handler then ) hope it will help